File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
src/generators/man-page/utils Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,12 @@ export function flagValueToMandoc(flag) {
7878 }
7979
8080 // Split the flag into the name and value based on the separator ('=' or space).
81- const value = flag . split ( sep ) [ 1 ] ;
81+ let value = flag . split ( sep ) [ 1 ] ;
82+
83+ // If the value ends with ']', the flag's argument is optional.
84+ if ( value . endsWith ( ']' ) ) {
85+ value = '[' + value ;
86+ }
8287
8388 // If there is no value, return an empty string.
8489 if ( ! value ) {
@@ -89,12 +94,12 @@ export function flagValueToMandoc(flag) {
8994 const prefix = sep === ' ' ? '' : ' Ns = Ns' ;
9095
9196 // Combine prefix and formatted value.
92- return `${ prefix } Ar ${ value . replace ( / \] $ / , '' ) } ` ;
97+ return `${ prefix } Ar ${ value } ` ;
9398}
9499
95100const formatFlag = flag =>
96101 // 'Fl' denotes a flag, followed by an optional 'Ar' (argument).
97- `Fl ${ flag . split ( / [ = ] / ) [ 0 ] . slice ( 1 ) } ${ flagValueToMandoc ( flag ) } ` ;
102+ `Fl ${ flag . split ( / \[ ? [ = ] / ) [ 0 ] . slice ( 1 ) } ${ flagValueToMandoc ( flag ) } ` ;
98103
99104/**
100105 * Converts an API option metadata entry into the Mandoc format.
You can’t perform that action at this time.
0 commit comments