You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(pretty): Fix bug where commands and options were displayed in the… (#17)
## Pull Request: Add Support for Parsing and Rendering Command Tables in
Markdown CLI Docs
### Summary
This PR enhances the `pretty.py` module to support parsing and rendering
a **Commands** section in CLI documentation. The changes allow the
system to recognize, store, and output tables of subcommands (with names
and descriptions) in both the markdown-to-tree and tree-to-markdown
conversions.
### Details
- **New Model:**
- Added a `CommandEntry` Pydantic model to represent individual commands
with `name` and `description` fields.
- Updated the `CommandNode` model to include a `commands:
List[CommandEntry]` field.
- **Markdown Parsing (`parse_markdown_to_tree`):**
- Recognizes the `**Commands**:` section in markdown.
- Parses each command entry (name and description) and adds it to the
`commands` list of the current command node.
- Handles both the standard `* `name`: description` and fallback `*
`name`` formats.
- **Markdown Rendering (`tree_to_markdown`):**
- Adds a "Commands" table to the generated markdown if any commands are
present.
- Formats the table with columns for "Name" and "Description".
- **Other Improvements:**
- Ensures section state is correctly managed when switching between
arguments, options, and commands.
- Adds tests for edge cases in command parsing and rendering.
### Motivation
This change makes the CLI documentation more comprehensive by including
a structured list of subcommands, improving both the parsing of existing
markdown and the generation of new documentation.
### Example
A markdown section like:
```markdown
**Commands**:
* `serve`: Start the server
* `build`: Build the project
```
Will now be parsed into the tree and rendered back as a markdown table.
---
**Closes:** #16
0 commit comments