[ ] function to tokenize command description as it permits mnemonics
[x] command examples
[x] converting to representation with mnemonics and placeholders
[x] redesign naming convention to make names more concise
Layout, summary and other things are validated in each get request. At the basic level all parser API functions check page layout. But if there are additional checks available for the requested item (like summary) then they are done too.
Usage
API usage
Extracting info about the first placeholder in the first example:
declare page='# grep
> Find patterns in files using regular expressions
> More information: https://www.gnu.org/software/grep/manual/grep.html
- Search for a pattern within a file:
`grep "{string value: foo[12]}" {file value}`
- Search for an exact string (disables regular expressions):
`grep --fixed-strings "{string value: blabla}" {file value}`'
declare tokens="$(parser_output_command_example_code_tokens "$page" 0)"
declare first_placeholder="$(__parser_output_token_value "$tokens" 1)"
echo "placeholder type: $(parser_output_command_example_code_placeholder_alternative_type "$first_placeholder")"
echo "placeholder explanation: $(parser_output_command_example_code_placeholder_alternative_description "$first_placeholder")"
echo "placeholder examples: $(parser_output_command_example_code_placeholder_alternative_examples "$first_placeholder")"
Example expansion in action
Input page:
# [[
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test
- Test if a specific variable is (equal|not equal) to a string:
`[[ "${string variable: foo}" {string operator: ==|string operator: !=} "{string string: Hello world!}" ]]`
- Test if a specific variable is ([eq]ual|[n]ot [e]qual|[g]reater [t]han|[l]ess [t]han|[g]reater than or [e]qual|[l]ess than or [e]qual) to a number:
`[[ "${string variable: foo}" {string operator: -eq|string operator: -ne|string operator: -gt|string operator: -lt|string operator: -ge|string operator: -le} {string number: 1} ]]`' 0
echo "STATUS = $?"
Output page (just examples):
- Test if a specific variable is equal to a string:
`[[ "${string variable: foo}" {string operator: ==} "{string string: Hello world!}" ]]`
- Test if a specific variable is not equal to a string:
`[[ "${string variable: foo}" {string operator: !=} "{string string: Hello world!}" ]]`
- Test if a specific variable is [eq]ual to a number:
`[[ "${string variable: foo}" {string operator: -eq} {string number: 1} ]]`
- Test if a specific variable is [n]ot [e]qual to a number:
`[[ "${string variable: foo}" {string operator: -ne} {string number: 1} ]]`
- Test if a specific variable is [g]reater [t]han to a number:
`[[ "${string variable: foo}" {string operator: -gt} {string number: 1} ]]`
- Test if a specific variable is [l]ess [t]han to a number:
`[[ "${string variable: foo}" {string operator: -lt} {string number: 1} ]]`
- Test if a specific variable is [g]reater than or [e]qual to a number:
`[[ "${string variable: foo}" {string operator: -ge} {string number: 1} ]]`
- Test if a specific variable is [l]ess than or [e]qual to a number:
`[[ "${string variable: foo}" {string operator: -le} {string number: 1} ]]`
closes #19
ToDo
Now the following things are parsed:
Layout, summary and other things are validated in each get request. At the basic level all parser API functions check page layout. But if there are additional checks available for the requested item (like summary) then they are done too.
Usage
API usage
Extracting info about the first placeholder in the first example:
Example expansion in action
Input page:
Output page (just examples):