Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit 02917de

Browse files
author
Matus Novak
committed
Implementing templates via Jinja2
Added Class Hierarchy page (Correctly shows inheritance of classes and structs) Added Class Member Functions page Added Class Member Variables page Added Class Member Typedefs page Added Class Member Enumerations page Added Namespace List page Added Namespace Members page Added Namespace Member Functions page Added Namespace Member Variables page Added Namespace Member Typedefs page Added Namespace Member Enumerations page Added Inherited member types and functions listings into the derived classes Use title when listing groups in modules.md Fix sometimes html sensitive characters (<>& etc.) not escaping properly Fix if source file has markdown codeblock ``` it would mess up output file Added "Implements" on member functions if they override a method from a base class Fixed anchors in VuePress (e.g. #function-hello-world) Fixed numbering of overloaded functions and their anchors Replaced anchoring on GitBook to use VuePress style anchoring
1 parent 366dce3 commit 02917de

File tree

162 files changed

+6486
-4348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+6486
-4348
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@ dist/
109109
example/temp
110110
*-old
111111
.vscode
112+
temp/

README.md

+80-41
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# doxybook
1+
# DoxyBook
22

33
This python tool will take an xml output generated by the Doxygen and converts that into markdown to be used by GitBook or Vuepress.
44

5+
Version v3.0.0 uses Jinja templates to generate Markdown files. The v3.0.0 is a massive overhaul of the XML processing and Markdown generation. **See the commit to see the changes.** The new v3.0.0 version has many bugfixes alongside with some additional namespace related files added into the output. If you are looking for old non templated version v2.1.6 then look into branch [doxybook/tree/v2.1.6](https://github.com/matusnovak/doxybook/tree/v2.1.6).
6+
57
## Live Demo
68

79
See live demo here for [Gitbook here](https://matusnovak.github.io/doxybook/gitbook/api/classexample_1_1_animal.html) or [Vuepress here](https://matusnovak.github.io/doxybook/vuepress/api/classexample_1_1_animal.html).
@@ -10,7 +12,11 @@ Alternativelly, the markdown files are located in the `doxybook/example/gitbook/
1012

1113
## Requirements
1214

13-
You need to have **python 3.6 or newer**. No additional python packages necessary, only the ones included by default in python itself.
15+
You need to have **python 3.6 or newer** and [Jinja2](http://jinja.pocoo.org/docs/2.10/intro/) package installed.
16+
17+
## Memory usage
18+
19+
Needs up to 100MiB of memory. Parsing super large projects can use up to 0.5GiB of memory. For example, a project consisting of 1000 Doxygen xml files can use 550MiB of memory, but I would be worried more about VuePress or GitBook memory usage while using that many files.
1420

1521
## Installation
1622

@@ -83,15 +89,18 @@ This tool was designed to copy the file naming and structure of Doxygen html out
8389
All classes, namespaces, structures, and interfaces are generated, including the following additional files:
8490

8591
* Directories (e.g. `dir_....md`)
86-
* Files - source code + file documentation (e.g. `filename_8h.md`)
87-
* Markdown pages through doxygen, highly do not recommend using this! (e.g. `md_src_....md`)
92+
* Files with source code + file documentation (e.g. `filename_8h.md`)
93+
* Markdown pages processed through doxygen, highly do not recommend using this! (e.g. `md_src_....md`)
94+
* Members (e.g. `class_xxx_yyy.md` or `namespace_xxx_yyy.md`)
8895
* Class List (e.g. `annotated.md`)
8996
* Class Index (e.g. `classes.md`)
90-
* Variable Index (e.g. `variables.md`)
91-
* Function Index (e.g. `functions.md`)
92-
* Enumeration Index (e.g. `enumerations.md`)
97+
* Class Members (e.g. `class_members.md`, `class_member_enums.md`, `class_member_functions.md`, `class_member_typedefs.md`, `class_member_variables.md`)
98+
* Class Hierarchy (.e.g `hierarchy.md`)
99+
* Namespace List (e.g. `namespaces.md`)
100+
* Namespace Members (e.g. `namespace_members.md`, `namespace_member_enums.md`, `namespace_member_functions.md`, `namespace_member_typedefs.md`, `namespace_member_variables.md`)
93101
* Modules/groups (e.g. `modules.md`)
94-
* Index page (if any) (e.g. `indexpage.md`)
102+
* Index page (if exists within Doxygen output as `indexpage.xml`) (e.g. `index.md`)
103+
* Any additional pages generated by Doxygen such as bugs, todo, tests
95104

96105
See the example folder to see all files.
97106

@@ -101,6 +110,7 @@ See the example folder to see all files.
101110
> python -m doxybook -h
102111
usage: __main__.py [-h] [-t TARGET] -i INPUT -o OUTPUT [-s SUMMARY] [-d DEBUG]
103112
[--noindex NOINDEX] [--hints HINTS]
113+
[--ignoreerrors IGNOREERRORS]
104114
105115
Convert doxygen XML output into GitBook or Vuepress markdown output.
106116
@@ -119,11 +129,13 @@ optional arguments:
119129
false)
120130
-d DEBUG, --debug DEBUG
121131
Debug the class hierarchy (default: false)
122-
--noindex NOINDEX If set to true, no search keywords will be generated
123-
at the file headers (default: false)
124132
--hints HINTS (Vuepress only) If set to true, hints will be
125133
generated for the sections note, bug, and a warning
126134
(default: true)
135+
--ignoreerrors IGNOREERRORS
136+
If set to true, will continue to generate Markdown
137+
files even if an error has been detected (default:
138+
false)
127139
```
128140

129141
## Detailed usage Vuepress
@@ -146,6 +158,10 @@ optional arguments:
146158
6. Run doxybook as: `doxybook -i temp/xml -o docs/api -s SUMMARY.md -t gitbook` (paths are relative) The `-s SUMMARY.md` is optional, if you provide a vaid path to the SUMMARY.md file then the doxybook will alter the contents with links to generated markdown files.
147159
7. Then build your GitBook as: `gitbook build`, or serve it as `gitbook serve` and go to `http://localhost:4000`, or upload the contents of `_book` folder into gh-pages on GitHub.
148160

161+
## Having errors while generating markdown files?
162+
163+
Run doxybook as `doxybook --ignoreerrors true -i ... -o ... -t ...`. The files will be generated, but some things may be missing.
164+
149165
## How does the SUMMARY.md work here? (Gitbook only)
150166

151167
GitBook has a big fault that anything not listed in `SUMMARY.md` will get ignored. Therefore the doxybook needs to alter the `SUMMARY.md`. Yes, this is optional, in case GitBook will be fixed in the future.
@@ -168,36 +184,59 @@ After running doxybook, the summary will become this code below. Notice how `* [
168184
# Summary
169185
170186
* [Introduction](README.md)
171-
* [Documentation](docs/api/index.md)
172-
* [Related Pages](docs/api/pages.md)
173-
* [Bug List](docs/api/bug.md)
174-
* [My Personal Index Page](docs/api/indexpage.md)
175-
* [Markdown test](docs/api/md_src_markdown-demo.md)
176-
* [Test List](docs/api/test.md)
177-
* [Todo List](docs/api/todo.md)
178-
* [Modules](docs/api/modules.md)
179-
* [animals](docs/api/group__animals.md)
180-
* [Class Index](docs/api/classes.md)
181-
* [Class List](docs/api/annotated.md)
182-
* [namespace example](docs/api/namespaceexample.md)
183-
* [class Animal](docs/api/classexample_1_1_animal.md)
184-
* [struct Result](docs/api/structexample_1_1_animal_1_1_result.md)
185-
* [class Bird](docs/api/classexample_1_1_bird.md)
186-
* [class CustomException](docs/api/classexample_1_1_custom_exception.md)
187-
* [class SpecialBird](docs/api/classexample_1_1_special_bird.md)
188-
* [Files](docs/api/files.md)
189-
* [src/](docs/api/dir_68267d1309a1af8e8297ef4c3efbcdba.md)
190-
* [animal.h](docs/api/animal_8h.md)
191-
* [animal.h - source](docs/api/animal_8h_source.md)
192-
* [bird.h](docs/api/bird_8h.md)
193-
* [bird.h - source](docs/api/bird_8h_source.md)
194-
* [example.h](docs/api/example_8h.md)
195-
* [example.h - source](docs/api/example_8h_source.md)
196-
* [special_bird.h](docs/api/special__bird_8h.md)
197-
* [special_bird.h - source](docs/api/special__bird_8h_source.md)
198-
* [utils/](docs/api/dir_313caf1132e152dd9b58bea13a4052ca.md)
199-
* [exception.h](docs/api/exception_8h.md)
200-
* [exception.h - source](docs/api/exception_8h_source.md)
187+
* [Documentation](api/index.md)
188+
* [Related Pages](api/pages.md)
189+
* [Bug List](api/bug.md)
190+
* [My Personal Index Page](api/indexpage.md)
191+
* [Markdown test](api/md_src_markdown-demo.md)
192+
* [Test List](api/test.md)
193+
* [Todo List](api/todo.md)
194+
* [Modules](api/modules.md)
195+
* [Some organism example](api/group__organism.md)
196+
* [An animal group example](api/group__animals.md)
197+
* [Class List](api/annotated.md)
198+
* [namespace example](api/namespaceexample.md)
199+
* [class example::Animal](api/classexample_1_1_animal.md)
200+
* [struct example::Animal::Result](api/structexample_1_1_animal_1_1_result.md)
201+
* [interface example::AnimalInterface](api/classexample_1_1_animal_interface.md)
202+
* [class example::Bird](api/classexample_1_1_bird.md)
203+
* [class example::CustomException](api/classexample_1_1_custom_exception.md)
204+
* [class example::NumericException](api/classexample_1_1_numeric_exception.md)
205+
* [class example::SpecialBird](api/classexample_1_1_special_bird.md)
206+
* [namespace example::inner_namespace](api/namespaceexample_1_1inner__namespace.md)
207+
* [class example::inner_namespace::Vector](api/classexample_1_1inner__namespace_1_1_vector.md)
208+
* [Namespace List](api/namespaces.md)
209+
* [Namespace Members](api/namespace_members.md)
210+
* [Namespace Member Functions](api/namespace_member_functions.md)
211+
* [Namespace Member Variables](api/namespace_member_variables.md)
212+
* [Namespace Member Typedefs](api/namespace_member_typedefs.md)
213+
* [Namespace Member Enumerations](api/namespace_member_enums.md)
214+
* [Class Index](api/classes.md)
215+
* [Class Hierarchy](api/hierarchy.md)
216+
* [Class Members](api/class_members.md)
217+
* [Class Member Functions](api/class_member_functions.md)
218+
* [Class Member Variables](api/class_member_variables.md)
219+
* [Class Member Typedefs](api/class_member_typedefs.md)
220+
* [Class Member Enumerations](api/class_member_enums.md)
221+
* [Files](api/files.md)
222+
* [markdown-demo.md](api/markdown-demo_8md.md)
223+
* [markdown-demo.md source](api/markdown-demo_8md_source.md)
224+
* [src](api/dir_68267d1309a1af8e8297ef4c3efbcdba.md)
225+
* [animal.h](api/animal_8h.md)
226+
* [animal.h source](api/animal_8h_source.md)
227+
* [animal_interface.h](api/animal__interface_8h.md)
228+
* [animal_interface.h source](api/animal__interface_8h_source.md)
229+
* [bird.h](api/bird_8h.md)
230+
* [bird.h source](api/bird_8h_source.md)
231+
* [config.h](api/config_8h.md)
232+
* [config.h source](api/config_8h_source.md)
233+
* [example.h](api/example_8h.md)
234+
* [example.h source](api/example_8h_source.md)
235+
* [special_bird.h](api/special__bird_8h.md)
236+
* [special_bird.h source](api/special__bird_8h_source.md)
237+
* [src/utils](api/dir_313caf1132e152dd9b58bea13a4052ca.md)
238+
* [exception.h](api/exception_8h.md)
239+
* [exception.h source](api/exception_8h_source.md)
201240
* [Something else](something-else.md)
202241
* [Go to my website](http://mywebsite.com/)
203242
```
@@ -215,7 +254,7 @@ After running doxybook, the summary will become this code below. Notice how `* [
215254
```
216255
MIT License
217256
218-
Copyright (c) 2018 Matus Novak
257+
Copyright (c) 2019 Matus Novak
219258
220259
Permission is hereby granted, free of charge, to any person obtaining a copy
221260
of this software and associated documentation files (the "Software"), to deal

doxybook/__init__.py

-140
Original file line numberDiff line numberDiff line change
@@ -1,140 +0,0 @@
1-
import argparse
2-
import sys
3-
import os
4-
import xml.etree.ElementTree
5-
6-
from doxybook.loader import load_root
7-
from doxybook.kind import Kind
8-
from doxybook.node import Node
9-
from doxybook.cache import Cache
10-
from doxybook.generators import (
11-
generate_annotated,
12-
generate_class_index,
13-
generate_dir,
14-
generate_file,
15-
generate_files,
16-
generate_member,
17-
generate_modules,
18-
generate_page,
19-
generate_pages,
20-
generate_summary,
21-
generate_function_index,
22-
generate_variable_index,
23-
generate_enum_index
24-
)
25-
from doxybook.config import config
26-
27-
def write_groups(index_path: str, output_path: str, node: Node, cache: Cache):
28-
for member in node.members:
29-
if member.kind == Kind.GROUP:
30-
generate_member(index_path, output_path, member.refid, cache)
31-
write_groups(index_path, output_path, member, cache)
32-
33-
def write_members(index_path: str, output_path: str, node: Node, cache: Cache):
34-
for member in node.members:
35-
if member.kind == Kind.STRUCT or member.kind == Kind.NAMESPACE or member.kind == Kind.CLASS or member.kind == Kind.INTERFACE:
36-
generate_member(index_path, output_path, member.refid, cache)
37-
write_members(index_path, output_path, member, cache)
38-
39-
def main():
40-
parser = argparse.ArgumentParser(description='Convert doxygen XML output into GitBook or Vuepress markdown output.')
41-
parser.add_argument('-t', '--target',
42-
type=str,
43-
help='Select the target: Gitbook (default) or Vuepress, for example: "-t vuepress" or "-t gitbook"',
44-
required=False,
45-
default=config.target
46-
)
47-
parser.add_argument('-i', '--input',
48-
type=str,
49-
help='Path to doxygen generated xml folder',
50-
required=True
51-
)
52-
parser.add_argument('-o', '--output',
53-
type=str,
54-
help='Path to the destination folder',
55-
required=True
56-
)
57-
parser.add_argument('-s', '--summary',
58-
type=str,
59-
help='Path to the summary file which contains a link to index.md in the folder pointed by --input (default: false)',
60-
required=False
61-
)
62-
parser.add_argument('-d', '--debug',
63-
type=bool,
64-
help='Debug the class hierarchy (default: false)',
65-
required=False,
66-
default=config.debug
67-
)
68-
parser.add_argument('--noindex',
69-
type=bool,
70-
help='If set to true, no search keywords will be generated at the file headers (default: false)',
71-
required=False,
72-
default=config.noindex
73-
)
74-
parser.add_argument('--hints',
75-
type=bool,
76-
help='(Vuepress only) If set to true, hints will be generated for the sections note, bug, and a warning (default: true)',
77-
required=False,
78-
default=config.hints
79-
)
80-
81-
args = parser.parse_args()
82-
83-
if args.target != 'gitbook' and args.target != 'vuepress':
84-
raise Exception('Unknown target: ' + str(args.target))
85-
86-
config.debug = args.debug
87-
config.target = args.target
88-
config.noindex = args.noindex
89-
config.hints = args.hints
90-
91-
if args.summary and not os.path.exists(args.summary):
92-
raise Exception('The provided summary file does not exist!')
93-
94-
if not os.path.exists(args.output) or not os.path.isdir(args.output):
95-
raise Exception('The target output directory does not exist!')
96-
97-
os.makedirs(args.output, exist_ok=True)
98-
cache = Cache()
99-
root = load_root(cache, args.input)
100-
101-
# Generate Index
102-
generate_class_index(args.output, root)
103-
generate_function_index(args.output, root)
104-
generate_variable_index(args.output, root)
105-
generate_enum_index(args.output, root)
106-
107-
# Generate Class List
108-
generate_annotated(args.input, args.output, root, cache)
109-
110-
# Write all members out
111-
write_members(args.input, args.output, root, cache)
112-
113-
# Generate modules page
114-
modules = generate_modules(args.input, args.output, root, cache)
115-
116-
# Write all grouos out
117-
write_groups(args.input, args.output, root, cache)
118-
119-
# Generate pages page
120-
pages = generate_pages(args.input, args.output, root, cache)
121-
122-
# Write all pages out
123-
for child in root.members:
124-
if child.kind == Kind.PAGE:
125-
generate_page(args.input, args.output, child.refid, cache)
126-
127-
# Generate files page
128-
files = generate_files(args.input, args.output, root, cache)
129-
130-
# Write all files out
131-
for child in root.members:
132-
if child.kind == Kind.FILE:
133-
generate_member(args.input, args.output, child.refid, cache)
134-
generate_file(args.input, args.output, child, cache)
135-
if child.kind == Kind.DIR:
136-
generate_dir(args.input, args.output, child, cache)
137-
138-
# Update summary
139-
if args.summary:
140-
generate_summary(args.output, args.summary, root, modules, pages, files)

0 commit comments

Comments
 (0)