Skip to content

Commit c2f5126

Browse files
Copilotneongreen
andcommitted
lion: Replace low-level docs with high-level user documentation examples
Co-authored-by: neongreen <1523306+neongreen@users.noreply.github.com>
1 parent fd56154 commit c2f5126

14 files changed

Lines changed: 276 additions & 32 deletions

lion/doc.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Getting Started:
2+
//
3+
// 1. Install lion: go install github.com/neongreen/mono/lion@latest
4+
// 2. Add lion comments to your Go code
5+
// 3. Run: lion generate
6+
// 4. Check the ./docs directory for generated markdown
7+
//
8+
// That's it! Lion will create one markdown file per topic.
9+
//lion:getting-started
10+
package main
11+
12+
// Best Practices:
13+
//
14+
// - Use marker-at-end format for cleaner code (recommended)
15+
// - Choose descriptive topic names (e.g., "getting-started", "api-reference")
16+
// - Group related documentation under the same topic
17+
// - Use hyphens in topic names, not spaces or underscores
18+
// - Keep topics focused - split large topics into smaller ones
19+
//
20+
// Topic names become filenames, so keep them filesystem-friendly.
21+
//lion:best-practices
22+
const _ = 0
23+
24+
// Common Use Cases:
25+
//
26+
// 1. Project guides: Create "getting-started", "installation", "configuration" topics
27+
// 2. Architecture docs: Use "architecture", "design-decisions", "data-flow" topics
28+
// 3. API documentation: Create "api-overview", "endpoints", "authentication" topics
29+
// 4. Troubleshooting: Use "troubleshooting", "faq", "known-issues" topics
30+
//
31+
// Lion works best for narrative documentation that explains concepts,
32+
// not for API reference (use godoc for that).
33+
//lion:use-cases
34+
const __ = 0
35+
36+
// Syntax Reference:
37+
//
38+
// Format 1 - Marker at end (recommended):
39+
// // Regular comment lines
40+
// // explaining functionality
41+
// //lion:topic-name
42+
//
43+
// Format 2 - Single line:
44+
// //lion:topic-name Your content here
45+
//
46+
// Format 3 - Block comment:
47+
// /*lion:topic-name
48+
// Your multi-line
49+
// content here
50+
// */
51+
//
52+
// All three formats generate identical output.
53+
// Choose the one that fits your documentation style.
54+
//lion:syntax-reference
55+
const ___ = 0
56+
57+
// Known Limitations:
58+
//
59+
// - Only processes .go files (not .md, .txt, etc.)
60+
// - Skips *_test.go files automatically
61+
// - Package comments must be BEFORE the package keyword
62+
// - No support for nested topics or hierarchies
63+
// - No cross-referencing between topics (yet)
64+
// - Output is always markdown (no HTML, PDF, etc.)
65+
//
66+
// These are intentional design decisions to keep lion simple and focused.
67+
//lion:known-limitations
68+
const ____ = 0
69+
70+
// Troubleshooting:
71+
//
72+
// Problem: "No documentation topics found"
73+
// Solution: Check that you're using the correct syntax and running
74+
// lion in the right directory.
75+
//
76+
// Problem: Package-level docs not showing up
77+
// Solution: Make sure the lion comment comes BEFORE "package foo"
78+
//
79+
// Problem: Marker-at-end not working
80+
// Solution: Ensure all lines before //lion:topic are regular comments
81+
// (no other //lion: markers in that comment block)
82+
//
83+
// Problem: Generated docs look wrong
84+
// Solution: Topics are combined from all files. Check for duplicate
85+
// topics in different files that might be merging.
86+
//lion:troubleshooting
87+
const _____ = 0

lion/docs/architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ runGenerate implements the generate command workflow.
2626

2727
It first extracts documentation using the extractor package, then generates markdown files using the generator package.
2828

29-
*Source: `main.go:70`*
29+
*Source: `main.go:86`*
3030

3131
## runTopics
3232

3333
runTopics implements the topics command.
3434

3535
It extracts documentation and prints a list of unique topic names found in the source code.
3636

37-
*Source: `main.go:93`*
37+
*Source: `main.go:109`*
3838

lion/docs/best-practices.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Best Practices
2+
3+
## _
4+
5+
Best Practices:
6+
- Use marker-at-end format for cleaner code (recommended)
7+
- Choose descriptive topic names (e.g., "getting-started", "api-reference")
8+
- Group related documentation under the same topic
9+
- Use hyphens in topic names, not spaces or underscores
10+
- Keep topics focused - split large topics into smaller ones
11+
Topic names become filenames, so keep them filesystem-friendly.
12+
13+
*Source: `doc.go:12`*
14+

lion/docs/cli.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,5 @@ The root command defines the main entry point for the lion CLI.
66

77
It uses Cobra for command-line parsing and includes subcommands for generate, topics, and version.
88

9-
*Source: `main.go:17`*
10-
11-
## generateCmd
12-
13-
The generate command scans Go files and creates markdown documentation.
14-
15-
It accepts an optional directory argument and an --output flag to specify where markdown files should be written.
16-
17-
*Source: `main.go:28`*
18-
19-
## topicsCmd
20-
21-
The topics command lists all documentation topics found in the codebase.
22-
23-
This is useful for getting an overview of available documentation before generating files.
24-
25-
*Source: `main.go:41`*
9+
*Source: `main.go:20`*
2610

lion/docs/getting-started.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Getting Started
2+
3+
## package main
4+
5+
Getting Started:
6+
1. Install lion: go install github.com/neongreen/mono/lion@latest
7+
2. Add lion comments to your Go code
8+
3. Run: lion generate
9+
4. Check the ./docs directory for generated markdown
10+
That's it! Lion will create one markdown file per topic.
11+
12+
*Source: `doc.go:1`*
13+
14+
## package main
15+
16+
lion extracts documentation from special comments in Go source code.
17+
It's designed for creating higher-level documentation like guides and references.
18+
This package demonstrates using lion for user-facing documentation rather than
19+
API documentation (which is what godoc is for).
20+
21+
*Source: `main.go:1`*
22+

lion/docs/implementation.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ It extracts lion comments from package declarations, function declarations, and
1919
## extractFromCommentGroup
2020

2121
extractFromCommentGroup processes a comment group and extracts lion comments.
22-
23-
It groups consecutive lion comments by topic, combines their content, and creates DocEntry records.
24-
25-
This allows multiple lion comments on the same entity to be merged into a single documentation entry per topic.
22+
It supports three formats:
23+
1. Single-line: //lion:topic Content (repeated on each line)
24+
2. Block: slash-star lion:topic Multi-line content star-slash
25+
3. Marker at end: Regular // comments followed by //lion:topic (pulls entire comment block)
26+
The marker-at-end format is cleanest for longer documentation blocks.
2627

2728
*Source: `internal/extractor/extractor.go:104`*
2829

@@ -32,7 +33,19 @@ parseLionCommentLine parses a single lion comment line.
3233

3334
The format is "lion:topic-name Optional content". It returns the topic name and content separately.
3435

35-
*Source: `internal/extractor/extractor.go:161`*
36+
*Source: `internal/extractor/extractor.go:254`*
37+
38+
## parseLionBlockComment
39+
40+
parseLionBlockComment parses a block comment that starts with lion:topic-name.
41+
The format allows multi-line content without repeating the topic on each line:
42+
/*lion:topic-name
43+
Multi-line content
44+
can go here
45+
*\/
46+
This returns the topic name and the full content (with the first line after lion:topic-name).
47+
48+
*Source: `internal/extractor/extractor.go:275`*
3649

3750
## generateTopicFile
3851

lion/docs/index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ This documentation was generated from lion comments in the source code.
55
## Topics
66

77
- [Architecture](architecture.md)
8+
- [Best Practices](best-practices.md)
89
- [Cli](cli.md)
10+
- [Getting Started](getting-started.md)
911
- [Implementation](implementation.md)
10-
- [Overview](overview.md)
12+
- [Known Limitations](known-limitations.md)
13+
- [Syntax Reference](syntax-reference.md)
14+
- [Troubleshooting](troubleshooting.md)
15+
- [Usage Guide](usage-guide.md)
16+
- [Use Cases](use-cases.md)

lion/docs/known-limitations.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Known Limitations
2+
3+
## ____
4+
5+
Known Limitations:
6+
- Only processes .go files (not .md, .txt, etc.)
7+
- Skips *_test.go files automatically
8+
- Package comments must be BEFORE the package keyword
9+
- No support for nested topics or hierarchies
10+
- No cross-referencing between topics (yet)
11+
- Output is always markdown (no HTML, PDF, etc.)
12+
These are intentional design decisions to keep lion simple and focused.
13+
14+
*Source: `doc.go:57`*
15+

lion/docs/syntax-reference.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Syntax Reference
2+
3+
## ___
4+
5+
Syntax Reference:
6+
Format 1 - Marker at end (recommended):
7+
// Regular comment lines
8+
// explaining functionality
9+
//lion:topic-name
10+
Format 2 - Single line:
11+
//lion:topic-name Your content here
12+
Format 3 - Block comment:
13+
/*lion:topic-name
14+
Your multi-line
15+
content here
16+
*/
17+
All three formats generate identical output.
18+
Choose the one that fits your documentation style.
19+
20+
*Source: `doc.go:36`*
21+

lion/docs/troubleshooting.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Troubleshooting
2+
3+
## _____
4+
5+
Troubleshooting:
6+
Problem: "No documentation topics found"
7+
Solution: Check that you're using the correct syntax and running
8+
lion in the right directory.
9+
Problem: Package-level docs not showing up
10+
Solution: Make sure the lion comment comes BEFORE "package foo"
11+
Problem: Marker-at-end not working
12+
Solution: Ensure all lines before //lion:topic are regular comments
13+
(no other //lion: markers in that comment block)
14+
Problem: Generated docs look wrong
15+
Solution: Topics are combined from all files. Check for duplicate
16+
topics in different files that might be merging.
17+
18+
*Source: `doc.go:70`*
19+

0 commit comments

Comments
 (0)