Skip to content

Commit 9f2b9e2

Browse files
committed
fix: simplify extract_description logic and fix bullet formatting
- Simplify description extraction to use single newline joins - Fix bullet list formatting: each bullet now on separate line - Remove complex paragraph joining logic (45 lines -> 28 lines) - Let Markdown handle formatting naturally - Maintain all Issue cocoindex-io#1108 requirements (backticks, no redundant blank lines) Addresses feedback from @georgeh0 in PR cocoindex-io#1210
1 parent 81736f3 commit 9f2b9e2

File tree

2 files changed

+27
-52
lines changed

2 files changed

+27
-52
lines changed

dev/generate_cli_docs.py

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ 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
178179

179180
for line in lines:
180181
if line.startswith("Usage:"):
@@ -186,44 +187,15 @@ def extract_description(help_text: str) -> str:
186187
stripped = line.strip()
187188
if stripped:
188189
description_lines.append(stripped)
190+
last_was_empty = False
189191
else:
190-
# Blank line - preserve as paragraph separator
191-
description_lines.append("")
192+
# Blank line - preserve as paragraph separator, avoid duplicates
193+
if description_lines and not last_was_empty:
194+
description_lines.append("")
195+
last_was_empty = True
192196

193-
# Join lines intelligently: preserve bullets, join regular text
194-
result = []
195-
i = 0
196-
while i < len(description_lines):
197-
line = description_lines[i]
198-
199-
# Empty line - paragraph separator
200-
if line == "":
201-
result.append("")
202-
i += 1
203-
continue
204-
205-
# Bullet list item - preserve as-is
206-
if line.startswith("-"):
207-
result.append(line)
208-
i += 1
209-
continue
210-
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 ""
197+
# Simply join with single newline - let Markdown handle paragraph formatting naturally
198+
description = "\n".join(description_lines) if description_lines else ""
227199
return escape_html_tags(description) # Escape HTML tags for MDX compatibility
228200

229201

docs/docs/core/cli-commands.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
### `drop`
66

7-
87
Drop the backend setup for flows.
98

10-
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...]`
9+
Modes of operation:
10+
1. Drop all flows defined in an app: `cocoindex drop <APP_TARGET>`
11+
2. Drop specific named flows: `cocoindex drop <APP_TARGET> [FLOW_NAME...]`
1112

1213

1314
**Usage:**
@@ -27,18 +28,19 @@ cocoindex drop [OPTIONS] [APP_TARGET] [FLOW_NAME]...
2728

2829
### `evaluate`
2930

30-
3131
Evaluate the flow and dump flow outputs to files.
3232

33-
Instead of updating the index, it dumps what should be indexed to files. Mainly used for evaluation purpose.
33+
Instead of updating the index, it dumps what should be indexed to files.
34+
Mainly used for evaluation purpose.
3435

3536
`APP_FLOW_SPECIFIER`: Specifies the application and optionally the target flow. Can be one of the following formats:
3637
- `path/to/your_app.py`
3738
- `an_installed.module_name`
3839
- `path/to/your_app.py:SpecificFlowName`
3940
- `an_installed.module_name:SpecificFlowName`
4041

41-
`:SpecificFlowName` can be omitted only if the application defines a single flow.
42+
`:SpecificFlowName` can be omitted only if the application defines a single
43+
flow.
4244

4345

4446
**Usage:**
@@ -59,12 +61,13 @@ cocoindex evaluate [OPTIONS] APP_FLOW_SPECIFIER
5961

6062
### `ls`
6163

62-
6364
List all flows.
6465

65-
If `APP_TARGET` (`path/to/app.py` or a module) is provided, lists flows defined in the app and their backend setup status.
66+
If `APP_TARGET` (`path/to/app.py` or a module) is provided, lists flows
67+
defined in the app and their backend setup status.
6668

67-
If `APP_TARGET` is omitted, lists all flows that have a persisted setup in the backend.
69+
If `APP_TARGET` is omitted, lists all flows that have a persisted setup in
70+
the backend.
6871

6972

7073
**Usage:**
@@ -83,7 +86,6 @@ cocoindex ls [OPTIONS] [APP_TARGET]
8386

8487
### `server`
8588

86-
8789
Start a HTTP server providing REST APIs.
8890

8991
It will allow tools like CocoInsight to access the server.
@@ -117,8 +119,8 @@ cocoindex server [OPTIONS] APP_TARGET
117119

118120
### `setup`
119121

120-
121-
Check and apply backend setup changes for flows, including the internal storage and target (to export to).
122+
Check and apply backend setup changes for flows, including the internal
123+
storage and target (to export to).
122124

123125
`APP_TARGET`: `path/to/app.py` or `installed_module`.
124126

@@ -140,17 +142,18 @@ cocoindex setup [OPTIONS] APP_TARGET
140142

141143
### `show`
142144

143-
144145
Show the flow spec and schema.
145146

146-
`APP_FLOW_SPECIFIER`: Specifies the application and optionally the target flow. Can be one of the following formats:
147+
`APP_FLOW_SPECIFIER`: Specifies the application and optionally the target
148+
flow. Can be one of the following formats:
147149

148150
- `path/to/your_app.py`
149151
- `an_installed.module_name`
150152
- `path/to/your_app.py:SpecificFlowName`
151153
- `an_installed.module_name:SpecificFlowName`
152154

153-
`:SpecificFlowName` can be omitted only if the application defines a single flow.
155+
`:SpecificFlowName` can be omitted only if the application defines a single
156+
flow.
154157

155158

156159
**Usage:**
@@ -171,10 +174,10 @@ cocoindex show [OPTIONS] APP_FLOW_SPECIFIER
171174

172175
### `update`
173176

174-
175177
Update the index to reflect the latest data from data sources.
176178

177-
`APP_FLOW_SPECIFIER`: `path/to/app.py`, module, `path/to/app.py:FlowName`, or `module:FlowName`. If `:FlowName` is omitted, updates all flows.
179+
`APP_FLOW_SPECIFIER`: `path/to/app.py`, module, `path/to/app.py:FlowName`,
180+
or `module:FlowName`. If `:FlowName` is omitted, updates all flows.
178181

179182

180183
**Usage:**

0 commit comments

Comments
 (0)