Skip to content

feat: generate a CLI help directory instead of 1 file - #55

Open
rschauner wants to merge 2 commits into
ConnorGray:mainfrom
rschauner:main
Open

feat: generate a CLI help directory instead of 1 file#55
rschauner wants to merge 2 commits into
ConnorGray:mainfrom
rschauner:main

Conversation

@rschauner

Copy link
Copy Markdown

When the CLI documentation gets quite large 5-10 commands, navigating the help can become cumbersome. I wanted to split each subcommand into a different file and link it all back to the main command.

Changes

  • Added a new field to MarkdownOptions for multiple files. It's set as an Enum for clarity, but is really a true/false option.
  • Created a new struct Markdown to hold the output from the help generation commands. It contains 2 Vec<String> fields, text and commands. It also has methods to write to disk (either single file or directory structure) and to convert to String.
  • build_command_markdown now accepts 2 new arguments vec_buffer and cmd_buffer. These two vectors hold the help text (vec_buffer) and the command path (cmd_buffer). The command path is built as a path.
  • build_table_of_contents_markdown now takes a markdown_options argument and returns contents formatted for a directory structure ("* command" or the existing single file structure ("* command").
  • I separated out some of the code blocks to separate functions for the footer, the preamble, subcommands.
  • I added 4 new public functions, all ending with "_md", that return the Markdown struct and implemented the existing functions to return String still.

Fixes

…ons customization

refactor: separate `build_command_markdown` into `write_usage`, `build_command_markdown_subcommands`, `build_command_markdown_parts`, and `write_preamble_markdown`.
- The signature also now includes 2 `Vec<String>`.
- `build_command_markdown_process` handles creating the vectors and returning a `Markdown` struct.
- The `Markdown` struct now holds the output and has methods to write to disk or display strings.
… options and examples

test: Add test for multiple files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant