mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	dump_cmds_json: Fix auto formatting
- Command list for script passes - Check buffer after loop - Close options properly - Ignore mismatched sigs e.g. `fsm_detect` on `fsm` - Require double blank line before new signature
This commit is contained in:
		
							parent
							
								
									00b6d96aee
								
							
						
					
					
						commit
						8d1b9b1c1f
					
				
					 1 changed files with 17 additions and 6 deletions
				
			
		|  | @ -848,7 +848,7 @@ struct HelpPass : public Pass { | |||
| 				size_t def_strip_count = 0; | ||||
| 				auto current_state = PUState_none; | ||||
| 				auto catch_verific = false; | ||||
| 				auto blank_lines = 0; | ||||
| 				auto blank_lines = 2; | ||||
| 				for (string line; std::getline(ss, line, '\n');) { | ||||
| 					// find position of first non space character
 | ||||
| 					std::size_t first_pos = line.find_first_not_of(" \t"); | ||||
|  | @ -880,9 +880,9 @@ struct HelpPass : public Pass { | |||
| 					bool IsIndent = def_strip_count < first_pos; | ||||
| 
 | ||||
| 					// line looks like a signature
 | ||||
| 					bool IsSignature = stripped_line.find(name) == 0; | ||||
| 					bool IsSignature = stripped_line.find(name) == 0 && (stripped_line.length() == name.length() || stripped_line.at(name.size()) == ' '); | ||||
| 
 | ||||
| 					if (IsSignature) { | ||||
| 					if (IsSignature && first_pos <= 4 && (blank_lines >= 2 || current_state == PUState_signature)) { | ||||
| 						if (current_state == PUState_options || current_state == PUState_optionbody) { | ||||
| 							cmd_help.codeblock(current_buffer, "none", null_source); | ||||
| 							current_buffer = ""; | ||||
|  | @ -900,14 +900,20 @@ struct HelpPass : public Pass { | |||
| 					} else if (IsDedent) { | ||||
| 						def_strip_count = first_pos; | ||||
| 						if (current_state == PUState_optionbody) { | ||||
| 							current_state = PUState_options; | ||||
| 							if (!current_buffer.empty()) { | ||||
| 								cmd_help.codeblock(current_buffer, "none", null_source); | ||||
| 								current_buffer = ""; | ||||
| 							} | ||||
| 						} | ||||
| 						else | ||||
| 							if (IsIndent) { | ||||
| 								current_state = PUState_options; | ||||
| 								cmd_help.close(1); | ||||
| 							} else { | ||||
| 								current_state = PUState_none; | ||||
| 								cmd_help.close(2); | ||||
| 							} | ||||
| 						} else { | ||||
| 							current_state = PUState_none; | ||||
| 						} | ||||
| 					} | ||||
| 
 | ||||
| 					if (IsDefinition && !catch_verific && current_state != PUState_signature) { | ||||
|  | @ -940,6 +946,11 @@ struct HelpPass : public Pass { | |||
| 					} | ||||
| 					blank_lines = 0; | ||||
| 				} | ||||
| 
 | ||||
| 				if (!current_buffer.empty()) { | ||||
| 					cmd_help.codeblock(current_buffer, "none", null_source); | ||||
| 					current_buffer = ""; | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			// write to json
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue