mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Fixed remove comments example
This commit is contained in:
		
							parent
							
								
									54723c1a36
								
							
						
					
					
						commit
						d3b2e37b66
					
				| @ -78,17 +78,22 @@ b: dog # leave this | |||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Remove all comments | ## Remove all comments | ||||||
|  | Note the use of `...` to ensure key nodes are included. | ||||||
|  | 
 | ||||||
| Given a sample.yml file of: | Given a sample.yml file of: | ||||||
| ```yaml | ```yaml | ||||||
| a: cat # comment | a: cat # comment | ||||||
|  | # great | ||||||
|  | b: # key comment | ||||||
| ``` | ``` | ||||||
| then | then | ||||||
| ```bash | ```bash | ||||||
| yq eval '.. comments=""' sample.yml | yq eval '... comments=""' sample.yml | ||||||
| ``` | ``` | ||||||
| will output | will output | ||||||
| ```yaml | ```yaml | ||||||
| a: cat | a: cat | ||||||
|  | b: | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Get line comment | ## Get line comment | ||||||
|  | |||||||
| @ -71,11 +71,12 @@ var commentOperatorScenarios = []expressionScenario{ | |||||||
| 		}, | 		}, | ||||||
| 	}, | 	}, | ||||||
| 	{ | 	{ | ||||||
| 		description: "Remove all comments", | 		description:    "Remove all comments", | ||||||
| 		document:    "# hi\n\na: cat # comment\n\n# great\n", | 		subdescription: "Note the use of `...` to ensure key nodes are included.", | ||||||
| 		expression:  `.. comments=""`, | 		document:       "# hi\n\na: cat # comment\n\n# great\n\nb: # key comment", | ||||||
|  | 		expression:     `... comments=""`, | ||||||
| 		expected: []string{ | 		expected: []string{ | ||||||
| 			"D0, P[], (!!map)::a: cat\n", | 			"D0, P[], (!!map)::a: cat\nb:\n", | ||||||
| 		}, | 		}, | ||||||
| 	}, | 	}, | ||||||
| 	{ | 	{ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user