Skip to content

Commit 9ee2cb6

Browse files
committed
Add breathe integration
1 parent a7acb63 commit 9ee2cb6

File tree

14 files changed

+1415
-47
lines changed

14 files changed

+1415
-47
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
with:
4040
version: ${{ matrix.python-version }}
4141

42+
- name: Install doxygen
43+
run: sudo apt-get install -y doxygen
44+
4245
- name: Install dependencies
4346
run: make develop
4447

.github/workflows/docs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ jobs:
1010
docs:
1111
runs-on: ubuntu-latest
1212
steps:
13+
- uses: actions/checkout@v6
14+
15+
- name: Install doxygen
16+
run: sudo apt-get install -y doxygen
17+
1318
- uses: actions-ext/yardang@main
1419
with:
1520
token: ${{ secrets.GITHUB_TOKEN }}

docs/src/api.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# API Reference
2+
3+
## Python API
4+
5+
### yardang.build
6+
7+
```{eval-rst}
8+
.. automodule:: yardang.build
9+
:members:
10+
:undoc-members:
11+
:show-inheritance:
12+
```
13+
14+
### yardang.cli
15+
16+
```{eval-rst}
17+
.. automodule:: yardang.cli
18+
:members:
19+
:undoc-members:
20+
:show-inheritance:
21+
```
22+
23+
### yardang.utils
24+
25+
```{eval-rst}
26+
.. automodule:: yardang.utils
27+
:members:
28+
:undoc-members:
29+
:show-inheritance:
30+
```
31+
32+
## C++ Example
33+
34+
This is an example of documenting C++ code using breathe integration.
35+
36+
### Document Everything
37+
38+
Use `doxygenindex` to document all symbols from Doxygen XML:
39+
40+
```doxygenindex
41+
```
42+
43+
### Document Individual Classes
44+
45+
Or document specific classes with `doxygenclass`:
46+
47+
```doxygenclass calc::Calculator
48+
:members:
49+
```
50+
51+
```doxygenclass calc::ScientificCalculator
52+
:members:
53+
```
54+

docs/src/configuration.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,195 @@ GitHub admonitions are automatically translated to sphinx.
278278
> [!CAUTION]
279279
> Caution content
280280
281+
## Breathe/Doxygen Integration
282+
283+
Yardang provides integration with [Breathe](https://breathe.readthedocs.io/) for documenting C/C++ code using Doxygen. To use this feature, install yardang with the breathe extra:
284+
285+
```bash
286+
pip install yardang[breathe]
287+
```
288+
289+
All breathe configuration is under `[tool.yardang.breathe]`.
290+
291+
### `projects`
292+
293+
A dictionary mapping project names to their Doxygen XML output directories.
294+
295+
```toml
296+
[tool.yardang.breathe]
297+
projects = { myproject = "docs/doxygen/xml", another = "path/to/xml" }
298+
```
299+
300+
### `default-project`
301+
302+
The default project to use when no project is specified in breathe directives.
303+
304+
```toml
305+
[tool.yardang.breathe]
306+
default-project = "myproject"
307+
```
308+
309+
### `domain-by-extension`
310+
311+
Map file extensions to Sphinx domains.
312+
313+
```toml
314+
[tool.yardang.breathe]
315+
domain-by-extension = { "hpp" = "cpp", "h" = "cpp", "py" = "py" }
316+
```
317+
318+
### `domain-by-file-pattern`
319+
320+
Map file patterns to Sphinx domains.
321+
322+
```toml
323+
[tool.yardang.breathe]
324+
domain-by-file-pattern = { "*.hpp" = "cpp" }
325+
```
326+
327+
### `projects-source`
328+
329+
Configure source files for automatic Doxygen XML generation.
330+
331+
```toml
332+
[tool.yardang.breathe]
333+
projects-source = { auto = ["src", ["file1.hpp", "file2.hpp"]] }
334+
```
335+
336+
### `build-directory`
337+
338+
The directory where Doxygen XML is built.
339+
340+
```toml
341+
[tool.yardang.breathe]
342+
build-directory = "build/doxygen"
343+
```
344+
345+
### `default-members`
346+
347+
Default member visibility for doxygenclass directives.
348+
349+
```toml
350+
[tool.yardang.breathe]
351+
default-members = ["members", "protected-members", "private-members"]
352+
```
353+
354+
### `show-define-initializer`
355+
356+
Show the initializer value for #define macros.
357+
358+
```toml
359+
[tool.yardang.breathe]
360+
show-define-initializer = true
361+
```
362+
363+
### `show-enumvalue-initializer`
364+
365+
Show the initializer value for enum values.
366+
367+
```toml
368+
[tool.yardang.breathe]
369+
show-enumvalue-initializer = true
370+
```
371+
372+
### `show-include`
373+
374+
Show the #include directive for documented entities.
375+
376+
```toml
377+
[tool.yardang.breathe]
378+
show-include = true
379+
```
380+
381+
### `implementation-filename-extensions`
382+
383+
List of file extensions considered as implementation files.
384+
385+
```toml
386+
[tool.yardang.breathe]
387+
implementation-filename-extensions = [".c", ".cc", ".cpp"]
388+
```
389+
390+
### `doxygen-config-options`
391+
392+
Additional Doxygen configuration options for auto-generated XML.
393+
394+
```toml
395+
[tool.yardang.breathe]
396+
doxygen-config-options = { EXTRACT_ALL = "YES", QUIET = "YES" }
397+
```
398+
399+
### `doxygen-aliases`
400+
401+
Doxygen aliases for custom commands.
402+
403+
```toml
404+
[tool.yardang.breathe]
405+
doxygen-aliases = { "myalias" = "Custom documentation text" }
406+
```
407+
408+
### `use-project-refids`
409+
410+
Use project-qualified reference IDs to avoid conflicts.
411+
412+
```toml
413+
[tool.yardang.breathe]
414+
use-project-refids = true
415+
```
416+
417+
### `order-parameters-first`
418+
419+
Order function parameters before other members in documentation.
420+
421+
```toml
422+
[tool.yardang.breathe]
423+
order-parameters-first = true
424+
```
425+
426+
### `separate-member-pages`
427+
428+
Generate separate pages for each class member.
429+
430+
```toml
431+
[tool.yardang.breathe]
432+
separate-member-pages = false
433+
```
434+
435+
### Complete Example
436+
437+
Here's a complete example configuration for a C++ project:
438+
439+
```toml
440+
[tool.yardang]
441+
title = "My C++ Library"
442+
root = "docs/index.md"
443+
pages = ["docs/api.md", "docs/examples.md"]
444+
use-autoapi = false
445+
446+
[tool.yardang.breathe]
447+
projects = { mylib = "docs/doxygen/xml" }
448+
default-project = "mylib"
449+
domain-by-extension = { "hpp" = "cpp", "cpp" = "cpp", "h" = "cpp" }
450+
show-define-initializer = true
451+
show-enumvalue-initializer = true
452+
show-include = true
453+
use-project-refids = true
454+
```
455+
456+
Then in your documentation files, you can use breathe directives:
457+
458+
```markdown
459+
# API Reference
460+
461+
## MyClass
462+
463+
\`\`\`{doxygenclass} MyNamespace::MyClass
464+
:members:
465+
:protected-members:
466+
\`\`\`
467+
468+
## Functions
469+
470+
\`\`\`{doxygenfunction} MyNamespace::myFunction
471+
\`\`\`
472+
```

examples/cpp/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Generated files
2+
xml/
3+
docs/html/
4+
5+
# Build artifacts
6+
*.o
7+
*.a
8+
*.so
9+
*.dylib
10+
11+
# IDE files
12+
.idea/
13+
.vscode/
14+
*.swp
15+
*.swo

examples/cpp/Doxyfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Doxyfile for the Calculator example project
2+
# This configuration generates XML output for use with Breathe
3+
4+
PROJECT_NAME = "Calculator Library"
5+
PROJECT_NUMBER = "1.0.0"
6+
PROJECT_BRIEF = "A simple C++ calculator library"
7+
OUTPUT_DIRECTORY = xml
8+
GENERATE_XML = YES
9+
GENERATE_HTML = NO
10+
GENERATE_LATEX = NO
11+
INPUT = include src
12+
RECURSIVE = YES
13+
FILE_PATTERNS = *.hpp *.cpp *.h *.c
14+
EXTRACT_ALL = YES
15+
EXTRACT_PRIVATE = YES
16+
EXTRACT_STATIC = YES
17+
EXTRACT_LOCAL_CLASSES = YES
18+
CASE_SENSE_NAMES = NO
19+
QUIET = YES
20+
WARN_IF_UNDOCUMENTED = YES
21+
WARN_IF_DOC_ERROR = YES
22+
JAVADOC_AUTOBRIEF = YES
23+
QT_AUTOBRIEF = YES
24+
BUILTIN_STL_SUPPORT = YES
25+
XML_OUTPUT = .
26+
XML_PROGRAMLISTING = YES

examples/cpp/docs/api.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Calculator C++ API Documentation
2+
3+
This page demonstrates how to use breathe to document C++ code with yardang.
4+
5+
## Calculator Class
6+
7+
```{doxygenclass} calc::Calculator
8+
:members:
9+
:protected-members:
10+
```
11+
12+
## ScientificCalculator Class
13+
14+
```{doxygenclass} calc::ScientificCalculator
15+
:members:
16+
```
17+
18+
## Enumerations
19+
20+
### Operation Enum
21+
22+
```{doxygenenum} calc::Operation
23+
```
24+
25+
## Structures
26+
27+
### OperationResult
28+
29+
```{doxygenstruct} calc::OperationResult
30+
:members:
31+
```
32+
33+
## Functions
34+
35+
### formatNumber
36+
37+
```{doxygenfunction} calc::formatNumber
38+
```
39+
40+
## Defines
41+
42+
```{doxygendefine} MAX_HISTORY_SIZE
43+
```
44+
45+
## Type Definitions
46+
47+
```{doxygentypedef} calc::HistoryList
48+
```

0 commit comments

Comments
 (0)