Skip to content

Commit 81736f3

Browse files
committed
fix: improve bullet list formatting and simplify description logic
- Fix bullet list formatting: each bullet now on separate line - Simplify extract_description logic as suggested by reviewer - Intelligently join regular paragraphs while preserving bullet lists - Maintain all Issue #1108 requirements (backticks, no mid-sentence breaks) Addresses feedback from PR #1210
1 parent fa9f444 commit 81736f3

File tree

2 files changed

+64
-25
lines changed

2 files changed

+64
-25
lines changed

dev/generate_cli_docs.py

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ def extract_description(help_text: str) -> str:
175175
# Find the description between usage and options/commands
176176
description_lines = []
177177
in_description = False
178-
last_was_empty = False
179178

180179
for line in lines:
181180
if line.startswith("Usage:"):
@@ -184,35 +183,47 @@ def extract_description(help_text: str) -> str:
184183
elif line.strip() in ["Options:", "Commands:"]:
185184
break
186185
elif in_description:
187-
if line.strip():
188-
# Non-empty line
189-
description_lines.append(line.strip())
190-
last_was_empty = False
186+
stripped = line.strip()
187+
if stripped:
188+
description_lines.append(stripped)
191189
else:
192-
# Empty line - only add one blank line to separate paragraphs
193-
if description_lines and not last_was_empty:
194-
description_lines.append("")
195-
last_was_empty = True
190+
# Blank line - preserve as paragraph separator
191+
description_lines.append("")
196192

197-
# Join lines, treating consecutive lines as same paragraph unless separated by blank line
193+
# Join lines intelligently: preserve bullets, join regular text
198194
result = []
199-
current_paragraph = []
195+
i = 0
196+
while i < len(description_lines):
197+
line = description_lines[i]
200198

201-
for line in description_lines:
199+
# Empty line - paragraph separator
202200
if line == "":
203-
# Blank line - end current paragraph
204-
if current_paragraph:
205-
result.append(" ".join(current_paragraph))
206-
current_paragraph = []
207-
else:
208-
current_paragraph.append(line)
201+
result.append("")
202+
i += 1
203+
continue
209204

210-
# Add any remaining paragraph
211-
if current_paragraph:
212-
result.append(" ".join(current_paragraph))
205+
# Bullet list item - preserve as-is
206+
if line.startswith("-"):
207+
result.append(line)
208+
i += 1
209+
continue
213210

214-
# Join paragraphs with double newline
215-
description = "\n\n".join(result) if result else ""
211+
# Regular text - join consecutive non-bullet, non-empty lines
212+
paragraph_lines = [line]
213+
i += 1
214+
while i < len(description_lines):
215+
next_line = description_lines[i]
216+
# Stop at empty line, bullet, or end
217+
if next_line == "" or next_line.startswith("-"):
218+
break
219+
paragraph_lines.append(next_line)
220+
i += 1
221+
222+
# Join paragraph lines with space
223+
result.append(" ".join(paragraph_lines))
224+
225+
# Join with single newline
226+
description = "\n".join(result) if result else ""
216227
return escape_html_tags(description) # Escape HTML tags for MDX compatibility
217228

218229

@@ -221,6 +232,11 @@ def generate_command_docs(cmd: click.Group) -> str:
221232

222233
markdown_content = []
223234

235+
# Disable lint warnings for about "first line in file should be a top level heading"
236+
# We intentionally start with a level 2 heading below, as this file is imported into another file.
237+
markdown_content.append("<!-- markdownlint-disable MD041 -->")
238+
markdown_content.append("")
239+
224240
# Add top-level heading to satisfy MD041 linting rule
225241
markdown_content.append("## Subcommands Reference")
226242
markdown_content.append("")

docs/docs/core/cli-commands.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
<!-- markdownlint-disable MD041 -->
2+
13
## Subcommands Reference
24

35
### `drop`
46

7+
58
Drop the backend setup for flows.
69

710
Modes of operation: 1. Drop all flows defined in an app: `cocoindex drop <APP_TARGET>` 2. Drop specific named flows: `cocoindex drop <APP_TARGET> [FLOW_NAME...]`
811

12+
913
**Usage:**
1014

1115
```bash
@@ -23,14 +27,20 @@ cocoindex drop [OPTIONS] [APP_TARGET] [FLOW_NAME]...
2327

2428
### `evaluate`
2529

30+
2631
Evaluate the flow and dump flow outputs to files.
2732

2833
Instead of updating the index, it dumps what should be indexed to files. Mainly used for evaluation purpose.
2934

30-
`APP_FLOW_SPECIFIER`: Specifies the application and optionally the target flow. Can be one of the following formats: - `path/to/your_app.py` - `an_installed.module_name` - `path/to/your_app.py:SpecificFlowName` - `an_installed.module_name:SpecificFlowName`
35+
`APP_FLOW_SPECIFIER`: Specifies the application and optionally the target flow. Can be one of the following formats:
36+
- `path/to/your_app.py`
37+
- `an_installed.module_name`
38+
- `path/to/your_app.py:SpecificFlowName`
39+
- `an_installed.module_name:SpecificFlowName`
3140

3241
`:SpecificFlowName` can be omitted only if the application defines a single flow.
3342

43+
3444
**Usage:**
3545

3646
```bash
@@ -49,12 +59,14 @@ cocoindex evaluate [OPTIONS] APP_FLOW_SPECIFIER
4959

5060
### `ls`
5161

62+
5263
List all flows.
5364

5465
If `APP_TARGET` (`path/to/app.py` or a module) is provided, lists flows defined in the app and their backend setup status.
5566

5667
If `APP_TARGET` is omitted, lists all flows that have a persisted setup in the backend.
5768

69+
5870
**Usage:**
5971

6072
```bash
@@ -71,12 +83,14 @@ cocoindex ls [OPTIONS] [APP_TARGET]
7183

7284
### `server`
7385

86+
7487
Start a HTTP server providing REST APIs.
7588

7689
It will allow tools like CocoInsight to access the server.
7790

7891
`APP_TARGET`: `path/to/app.py` or `installed_module`.
7992

93+
8094
**Usage:**
8195

8296
```bash
@@ -103,10 +117,12 @@ cocoindex server [OPTIONS] APP_TARGET
103117

104118
### `setup`
105119

120+
106121
Check and apply backend setup changes for flows, including the internal storage and target (to export to).
107122

108123
`APP_TARGET`: `path/to/app.py` or `installed_module`.
109124

125+
110126
**Usage:**
111127

112128
```bash
@@ -124,14 +140,19 @@ cocoindex setup [OPTIONS] APP_TARGET
124140

125141
### `show`
126142

143+
127144
Show the flow spec and schema.
128145

129146
`APP_FLOW_SPECIFIER`: Specifies the application and optionally the target flow. Can be one of the following formats:
130147

131-
- `path/to/your_app.py` - `an_installed.module_name` - `path/to/your_app.py:SpecificFlowName` - `an_installed.module_name:SpecificFlowName`
148+
- `path/to/your_app.py`
149+
- `an_installed.module_name`
150+
- `path/to/your_app.py:SpecificFlowName`
151+
- `an_installed.module_name:SpecificFlowName`
132152

133153
`:SpecificFlowName` can be omitted only if the application defines a single flow.
134154

155+
135156
**Usage:**
136157

137158
```bash
@@ -150,10 +171,12 @@ cocoindex show [OPTIONS] APP_FLOW_SPECIFIER
150171

151172
### `update`
152173

174+
153175
Update the index to reflect the latest data from data sources.
154176

155177
`APP_FLOW_SPECIFIER`: `path/to/app.py`, module, `path/to/app.py:FlowName`, or `module:FlowName`. If `:FlowName` is omitted, updates all flows.
156178

179+
157180
**Usage:**
158181

159182
```bash

0 commit comments

Comments
 (0)