mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	cmdref: Export internal_flag to json
Commands flagged as internal will display a warning, just like experimental commands. Drop `passes/tests` group in favour of `internal` group, which is automatically assigned for any command without an assigned group which is flagged as internal.
This commit is contained in:
		
							parent
							
								
									d62a110dc8
								
							
						
					
					
						commit
						14fdc9e76c
					
				
					 5 changed files with 19 additions and 11 deletions
				
			
		
							
								
								
									
										5
									
								
								docs/source/cmd/index_internal.rst
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								docs/source/cmd/index_internal.rst
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | ||||||
|  | internal | ||||||
|  | ------------------ | ||||||
|  | 
 | ||||||
|  | .. autocmdgroup:: internal | ||||||
|  |    :members: | ||||||
|  | @ -1,5 +0,0 @@ | ||||||
| passes/tests |  | ||||||
| ------------------ |  | ||||||
| 
 |  | ||||||
| .. autocmdgroup:: passes/tests |  | ||||||
|    :members: |  | ||||||
|  | @ -19,4 +19,5 @@ Command line reference | ||||||
|    /cmd/index_formal |    /cmd/index_formal | ||||||
|    /cmd/index_passes* |    /cmd/index_passes* | ||||||
|    /cmd/index_techlibs |    /cmd/index_techlibs | ||||||
|  |    /cmd/index_internal | ||||||
|    /cmd/index_other |    /cmd/index_other | ||||||
|  |  | ||||||
|  | @ -53,6 +53,7 @@ class YosysCmd: | ||||||
|     source_line: int |     source_line: int | ||||||
|     source_func: str |     source_func: str | ||||||
|     experimental_flag: bool |     experimental_flag: bool | ||||||
|  |     internal_flag: bool | ||||||
| 
 | 
 | ||||||
|     def __init__( |     def __init__( | ||||||
|             self, |             self, | ||||||
|  | @ -62,7 +63,8 @@ class YosysCmd: | ||||||
|             source_file: str = "", |             source_file: str = "", | ||||||
|             source_line: int = 0, |             source_line: int = 0, | ||||||
|             source_func: str = "", |             source_func: str = "", | ||||||
|             experimental_flag: bool = False |             experimental_flag: bool = False, | ||||||
|  |             internal_flag: bool = False, | ||||||
|     ) -> None: |     ) -> None: | ||||||
|         self.name = name |         self.name = name | ||||||
|         self.title = title |         self.title = title | ||||||
|  | @ -72,6 +74,7 @@ class YosysCmd: | ||||||
|         self.source_line = source_line |         self.source_line = source_line | ||||||
|         self.source_func = source_func |         self.source_func = source_func | ||||||
|         self.experimental_flag = experimental_flag |         self.experimental_flag = experimental_flag | ||||||
|  |         self.internal_flag = internal_flag | ||||||
|      |      | ||||||
| class YosysCmdGroupDocumenter(Documenter): | class YosysCmdGroupDocumenter(Documenter): | ||||||
|     objtype = 'cmdgroup' |     objtype = 'cmdgroup' | ||||||
|  | @ -344,6 +347,10 @@ class YosysCmdDocumenter(YosysCmdGroupDocumenter): | ||||||
|             self.add_line(f'.. warning:: This command is experimental', source_name, source_line) |             self.add_line(f'.. warning:: This command is experimental', source_name, source_line) | ||||||
|             self.add_line('\n', source_name) |             self.add_line('\n', source_name) | ||||||
| 
 | 
 | ||||||
|  |         if self.object.internal_flag: | ||||||
|  |             self.add_line(f'.. warning:: This command is intended for internal developer use only', source_name, source_line) | ||||||
|  |             self.add_line('\n', source_name) | ||||||
|  | 
 | ||||||
|         def render(content_list: YosysCmdContentListing, indent: int=0): |         def render(content_list: YosysCmdContentListing, indent: int=0): | ||||||
|             content_source = content_list.source_file or source_name |             content_source = content_list.source_file or source_name | ||||||
|             indent_str = '   '*indent |             indent_str = '   '*indent | ||||||
|  |  | ||||||
|  | @ -842,7 +842,6 @@ struct HelpPass : public Pass { | ||||||
| 			auto name = it.first; | 			auto name = it.first; | ||||||
| 			auto pass = it.second; | 			auto pass = it.second; | ||||||
| 			auto title = pass->short_help; | 			auto title = pass->short_help; | ||||||
| 			auto experimental_flag = pass->experimental_flag; |  | ||||||
| 
 | 
 | ||||||
| 			auto cmd_help = PrettyHelp(); | 			auto cmd_help = PrettyHelp(); | ||||||
| 			auto has_pretty_help = pass->formatted_help(); | 			auto has_pretty_help = pass->formatted_help(); | ||||||
|  | @ -982,7 +981,9 @@ struct HelpPass : public Pass { | ||||||
| 			if (!cmd_help.has_group()) { | 			if (!cmd_help.has_group()) { | ||||||
| 				string source_file = pass->location.file_name(); | 				string source_file = pass->location.file_name(); | ||||||
| 				bool has_source = source_file.compare("unknown") != 0; | 				bool has_source = source_file.compare("unknown") != 0; | ||||||
| 				if (source_file.find("backends/") == 0 || (!has_source && name.find("read_") == 0)) | 				if (pass->internal_flag) | ||||||
|  | 					cmd_help.group = "internal"; | ||||||
|  | 				else if (source_file.find("backends/") == 0 || (!has_source && name.find("read_") == 0)) | ||||||
| 					cmd_help.group = "backends"; | 					cmd_help.group = "backends"; | ||||||
| 				else if (source_file.find("frontends/") == 0 || (!has_source && name.find("write_") == 0)) | 				else if (source_file.find("frontends/") == 0 || (!has_source && name.find("write_") == 0)) | ||||||
| 					cmd_help.group = "frontends"; | 					cmd_help.group = "frontends"; | ||||||
|  | @ -1006,8 +1007,6 @@ struct HelpPass : public Pass { | ||||||
| 					cmd_help.group = "passes/opt"; | 					cmd_help.group = "passes/opt"; | ||||||
| 				else if (name.find("proc") == 0) | 				else if (name.find("proc") == 0) | ||||||
| 					cmd_help.group = "passes/proc"; | 					cmd_help.group = "passes/proc"; | ||||||
| 				else if (name.find("test") == 0) |  | ||||||
| 					cmd_help.group = "passes/tests"; |  | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if (groups.count(cmd_help.group) == 0) { | 			if (groups.count(cmd_help.group) == 0) { | ||||||
|  | @ -1026,7 +1025,8 @@ struct HelpPass : public Pass { | ||||||
| 			json.entry("source_file", pass->location.file_name()); | 			json.entry("source_file", pass->location.file_name()); | ||||||
| 			json.entry("source_line", pass->location.line()); | 			json.entry("source_line", pass->location.line()); | ||||||
| 			json.entry("source_func", pass->location.function_name()); | 			json.entry("source_func", pass->location.function_name()); | ||||||
| 			json.entry("experimental_flag", experimental_flag); | 			json.entry("experimental_flag", pass->experimental_flag); | ||||||
|  | 			json.entry("internal_flag", pass->internal_flag); | ||||||
| 			json.end_object(); | 			json.end_object(); | ||||||
| 		} | 		} | ||||||
| 		json.end_object(); | 		json.end_object(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue