Skip to content

Commit e43524e

Browse files
Jonas Berghefloryd
authored andcommitted
New documentation templating
1 parent 239170d commit e43524e

File tree

11 files changed

+98
-64
lines changed

11 files changed

+98
-64
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ CMakeCache.txt
66
install
77
docs/_build
88

9+
# Python files
10+
*env*
11+
912
.cproject
1013
.project
1114
.dir-locals.el

docs/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (DOXYGEN_FOUND)
2222

2323
# Doxygen configuration
2424
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
25-
set(DOXYGEN_TYPEDEF_HIDES_STRUCT NO)
25+
set(DOXYGEN_TYPEDEF_HIDES_STRUCT YES)
2626
set(DOXYGEN_EXTRACT_ALL YES)
2727
set(DOXYGEN_EXTRACT_STATIC YES)
2828
set(DOXYGEN_STRIP_CODE_COMMENTS NO)
@@ -74,4 +74,14 @@ if (SPHINX_FOUND AND DOXYGEN_FOUND)
7474
add_sphinx_builder(sphinx-spelling spelling)
7575
add_sphinx_builder(sphinx-linkcheck linkcheck)
7676

77+
# Zip the documentation
78+
message("c-open revision: ${CANOPEN_GIT_REVISION}")
79+
add_custom_command(
80+
TARGET sphinx-html POST_BUILD
81+
COMMAND zip -FS -r copen_docs_${CANOPEN_GIT_REVISION}.zip sphinx/html/ > /dev/null
82+
COMMAND echo "The Sphinx HTML and ZIP files are located in ${CMAKE_CURRENT_BINARY_DIR}"
83+
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/copen_docs_${CANOPEN_GIT_REVISION}.zip
84+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
85+
COMMENT "Zipping HTML documentation")
86+
7787
endif()

docs/README.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
To build the documentation, it is important to use the sphinx-build script
2+
installed in your virtual environment.
3+
Use CMAKE_IGNORE_PATH to prevent cmake from using a script installed elsewhere
4+
5+
Run these commands (adapt to your needs):
6+
7+
python3 -m venv myvenv
8+
source myvenv/bin/activate
9+
pip3 install -r docs/requirements.txt
10+
11+
cmake -B build -DCMAKE_IGNORE_PATH:PATH=$HOME/.local/bin
12+
cmake --build build/ --target sphinx-html

docs/api_reference.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,30 @@ Callbacks
2323
Structs
2424
--------
2525

26-
.. doxygenstruct:: co_obj
26+
.. doxygenstruct:: co_obj_t
2727
:members:
2828
:undoc-members:
2929

30-
.. doxygenstruct:: co_entry
30+
.. doxygenstruct:: co_entry_t
3131
:members:
3232
:undoc-members:
3333

34-
.. doxygenstruct:: co_default
34+
.. doxygenstruct:: co_default_t
3535
:members:
3636
:undoc-members:
3737

38-
.. doxygenstruct:: co_cfg
38+
.. doxygenstruct:: co_cfg_t
3939
:members:
4040
:undoc-members:
4141

4242
Enums
4343
------
4444

45-
.. doxygenenum:: co_sdo_abort
46-
.. doxygenenum:: co_state
47-
.. doxygenenum:: co_nmt_cmd
48-
.. doxygenenum:: co_otype
49-
.. doxygenenum:: co_dtype
50-
.. doxygenenum:: od_event
51-
.. doxygenenum:: co_store
52-
.. doxygenenum:: co_mode
45+
.. doxygenenum:: co_sdo_abort_t
46+
.. doxygenenum:: co_state_t
47+
.. doxygenenum:: co_nmt_cmd_t
48+
.. doxygenenum:: co_otype_t
49+
.. doxygenenum:: co_dtype_t
50+
.. doxygenenum:: od_event_t
51+
.. doxygenenum:: co_store_t
52+
.. doxygenenum:: co_mode_t

docs/conf.py

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,29 @@
66

77
# -- Path setup --------------------------------------------------------------
88

9-
# If extensions (or modules to document with autodoc) are in another directory,
10-
# add these directories to sys.path here. If the directory is relative to the
11-
# documentation root, use os.path.abspath to make it absolute, like shown here.
12-
#
13-
# import os
14-
# import sys
15-
# sys.path.insert(0, os.path.abspath('.'))
9+
import pathlib
10+
import re
11+
import sys
12+
13+
import os
1614

1715

16+
pathobj_docs_dir = pathlib.Path(__file__).parent.absolute()
17+
pathobj_rootdir = pathobj_docs_dir.parent.absolute()
18+
1819
# -- Project information -----------------------------------------------------
1920

21+
try:
22+
cmakelists_contents = pathobj_rootdir.joinpath("CMakeLists.txt").read_text()
23+
versiontext_match = re.search(r"CANOPEN VERSION ([\d.]*)", cmakelists_contents)
24+
version = versiontext_match.group(1)
25+
except:
26+
version = "unknown version"
27+
2028
project = 'c-open'
21-
copyright = '2022, RT-Labs AB'
29+
copyright = '2023, RT-Labs AB'
2230
author = 'RT-Labs AB'
2331

24-
2532
# -- General configuration ---------------------------------------------------
2633

2734
# Add any Sphinx extension module names here, as strings. They can be
@@ -32,19 +39,19 @@
3239
"recommonmark",
3340
"sphinx_copybutton",
3441
"sphinx_jinja",
35-
"sphinx_rtd_theme",
3642
"sphinx.ext.autosectionlabel",
3743
"sphinx.ext.graphviz",
3844
"sphinxcontrib.kroki",
3945
"sphinxcontrib.programoutput",
4046
"sphinxcontrib.spelling",
4147
]
4248

49+
4350
# Spelling
4451
spelling_word_list_filename = "spelling-wordlist.txt"
4552

4653
# Add any paths that contain templates here, relative to this directory.
47-
templates_path = ['_templates']
54+
templates_path = ["../../_templates"]
4855

4956
# List of patterns, relative to source directory, that match files and
5057
# directories to ignore when looking for source files.
@@ -57,17 +64,28 @@
5764

5865
# -- Options for HTML output -------------------------------------------------
5966

60-
# TODO Fine-tune the CSS to adjust logo and API documentation appearance
61-
html_theme = "press"
67+
html_context = {
68+
"default_mode": "light"
69+
}
70+
71+
html_theme = "sphinx_book_theme"
72+
html_theme_options = {
73+
"show_nav_level": 3,
74+
"home_page_in_toc": True,
75+
"use_repository_button": True,
76+
"use_fullscreen_button": False,
77+
"navbar_end": ["navbar-icon-links"],
78+
"use_download_button": False,
79+
"repository_url": "https://github.com/rtlabs-com/c-open",
80+
}
81+
6282
html_last_updated_fmt = "%Y-%m-%d %H:%M"
6383
html_static_path = ["static"]
64-
html_logo = "illustrations/c-open.png"
84+
html_logo = "static/i/c-open.svg"
6585
html_show_sourcelink = False
66-
html_copy_sources = False
67-
html_show_sphinx = False
6886

69-
html_css_files = [
70-
"../../css/custom_rtd.css",
71-
"css/fix_table_width.css",
72-
"css/change_header_size.css",
73-
]
87+
if os.getenv("USE_EXTERNAL_CSS") is not None:
88+
html_css_files = [
89+
"https://rt-labs.com/content/themes/rtlabs2020/assets/css/style.css",
90+
"https://rt-labs.com/content/themes/rtlabs2020/assets/css/rt_custom_sphinx.css",
91+
]

docs/dependencies.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/illustrations/c-open.png

-6.54 KB
Binary file not shown.

docs/requirements.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
# Solve issue with missing bullet points
3+
# See https://stackoverflow.com/questions/67542699/readthedocs-sphinx-not-rendering-bullet-list-from-rst-file
4+
docutils==0.17.1
5+
6+
# Use versions that fit the docutils version
7+
breathe==4.34.0
8+
codespell==2.2.2
9+
graphviz==0.20.1
10+
myst-parser==0.18.1
11+
recommonmark==0.7.1
12+
rst2pdf==0.99
13+
rstcloth==0.5.3
14+
sphinx_book_theme==1.0.1
15+
sphinx-copybutton==0.5.1
16+
sphinx-jinja==2.0.2
17+
Sphinx==5.3.0
18+
sphinxcontrib-kroki==1.3.0
19+
sphinxcontrib-programoutput==0.17
20+
sphinxcontrib-spelling==8.0.0

docs/static/css/change_header_size.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/static/css/fix_table_width.css

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)