Skip to content

Commit bc7c2cc

Browse files
authored
Merge pull request #39 from LinuxJedi/document-documentation
Document the documentation
2 parents bf3e62e + 712bae5 commit bc7c2cc

File tree

10 files changed

+223
-299
lines changed

10 files changed

+223
-299
lines changed

CONTRIBUTING.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Contributing
2+
3+
## Editing Documentation
4+
5+
For each documentation directory you will find a `src` directory which contains chapter files. You can edit these chapter files to change the content.
6+
7+
The documentation uses [Python Markdown](https://python-markdown.github.io/) for the HTML documentation and [Pandoc's Markdown](https://pandoc.org/MANUAL.html#pandocs-markdown) for the PDF documentation. Any edits should strive to be compatible with both (for most things these two are compatible with each other).
8+
9+
## New Manual
10+
11+
### Files Needed
12+
13+
As a minimum a manual directory needs:
14+
15+
* header.txt
16+
* mkdocs.yml
17+
* Makefile
18+
* src directory
19+
20+
#### header.txt
21+
22+
The `header.txt` needs to have the following content (adjust the title for your manual). This is needed to generate the PDF output:
23+
24+
```
25+
% wolfBoot Documentation ![](logo.png)
26+
27+
---
28+
header-includes:
29+
# Blank pages on new sections
30+
- \usepackage{titlesec}
31+
- \newcommand{\sectionbreak}{\clearpage}
32+
# Fancy page headers
33+
- \usepackage{fancyhdr}
34+
- \pagestyle{fancy}
35+
- \fancyfoot[LO,RE]{COPYRIGHT \copyright 2021 wolfSSL Inc.}
36+
# Wrap long syntax highlighting code blocks
37+
- \usepackage{fvextra}
38+
- \DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}}
39+
# Wrap long non-sytax highlighted code blocks
40+
- \usepackage{listings}
41+
- \let\verbatim\undefined
42+
- \let\verbatimend\undefined
43+
- \lstnewenvironment{verbatim}{\lstset{breaklines,basicstyle=\ttfamily}}{}
44+
subparagraph: yes
45+
---
46+
```
47+
48+
#### mkdocs.yml
49+
50+
The `mkdocs.yml` file defines the layout for the HTML documentation output. It should be as below with the `site_name` and `nav` adjusted for your documentation. It can contain nested navigation, see `wolfSSL/mkdocs.yml` for a more complex example.
51+
52+
Your first documentation file in the `Makefile` will be renamed `index.md` for the HTML build.
53+
54+
```
55+
site_name: wolfBoot Manual
56+
site_url: https://wolfssl.com/
57+
docs_dir: build/html/
58+
site_dir: html/
59+
copyright: wolfSSL Inc. 2021
60+
nav:
61+
- "1. Introduction": index.md
62+
- "2. Compiling wolfBoot": chapter02.md
63+
- "3. Targets": chapter03.md
64+
- "4. Hardware Abstraction Layer": chapter04.md
65+
- "5. Flash Partitions": chapter05.md
66+
- "6. wolfBoot Features": chapter06.md
67+
- "7. Integrating wolfBoot in an existing project": chapter07.md
68+
- "8. Troubleshooting": chapter08.md
69+
theme:
70+
name: null
71+
custom_dir: ../mkdocs-material/material
72+
language: en
73+
palette:
74+
primary: indigo
75+
accent: indigo
76+
font:
77+
text: Roboto
78+
code: Roboto Mono
79+
icon: "logo.png"
80+
logo: logo.png
81+
favicon: logo.png
82+
feature:
83+
tabs: true
84+
extra_css: [skin.css]
85+
extra:
86+
generator: false
87+
use_directory_urls: false
88+
```
89+
90+
#### Makefile
91+
92+
The following is a minimal `Makefile` for a project:
93+
94+
```
95+
-include ../common/common.am
96+
.DEFAULT_GOAL := all
97+
all: pdf html
98+
99+
100+
SOURCES = chapter01.md \
101+
chapter02.md \
102+
chapter03.md \
103+
chapter04.md \
104+
chapter05.md \
105+
chapter06.md \
106+
chapter07.md \
107+
chapter08.md
108+
109+
PDF = wolfBoot-Manual.pdf
110+
111+
.PHONY: html-prep
112+
html-prep:
113+
114+
.PHONY: pdf-prep
115+
pdf-prep:
116+
```
117+
118+
The `common.am` contains has a lot of content to process the Markdown files into the HTML and PDF outputs. The `SOURCES` list should be changed to a list of your source Markdown files in the order you wish them to be rendered for the PDF. The `PDF` variable should be changed to your PDF output filename.
119+
120+
The `html-prep` should contain any additional steps you wish to make prior to rendering the HTML output and likewise the `pdf-prep` should contain additional steps for the PDF output.
121+
122+
There are more complex examples which also pull in Doxygen content from the project source code for appendices in `wolfTPM/Makefile` and `wolfSSL/Makefile`.
123+
124+
#### src Directory
125+
126+
The `src` directory contains the source Markdown documentation that will be compiled into PDF and HTML manuals.
127+
128+
### Docker Builds
129+
130+
The build process is quite complex with several required dependencies, particularly for the manuals that require Doxygen. Therefore a Docker based build has been created which will do all the hard work automatically without you having to install any dependencies (apart from Docker itself).
131+
132+
For every manual an entry needs to be added into the `Dockerfile` and `Makefile` at the root of this directory tree.
133+
134+
#### Dockerfile
135+
136+
A new entry needs to be added as below (modified for the project name / directories / files):
137+
138+
```
139+
# Build wolfBoot PDF
140+
FROM builder AS wolfboot-stage1
141+
WORKDIR /src/wolfssl/wolfBoot
142+
RUN make pdf
143+
144+
# Build wolfBoot HTML
145+
FROM builder AS wolfboot-stage2
146+
WORKDIR /src/wolfssl/wolfBoot
147+
RUN make html
148+
149+
# Build wolfBoot HTML and PDF
150+
FROM scratch AS wolfboot
151+
COPY --from=wolfboot-stage1 /src/wolfssl/wolfBoot/wolfBoot-Manual.pdf wolfboot.pdf
152+
COPY --from=wolfboot-stage2 /src/wolfssl/wolfBoot/html wolfboot-html
153+
```
154+
155+
The final `wolfboot.pdf` and `wolfboot-html` will be what is created in the `build` directory in the root of this directory tree at the end of the build.
156+
157+
#### Makefile
158+
159+
An entry also needs to be added to the `Makefile` at the root of this directory tree with the following contents (adjusted for the target at the third step of your Dockerfile entry):
160+
161+
```
162+
.PHONY: wolfboot
163+
wolfboot: build
164+
@$(DOCKER_CMD) --target=wolfboot
165+
```
166+
167+
You will also need to add an entry to the `all` line for your project.

README.md

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,66 @@
11
# Documentation
22

3-
## wolfSSL Directory
3+
This is the new build system for the various wolfSSL products' manuals, please see the READMEs each directory for more information. The advantages of this over previous wolfSSL manuals are:
44

5-
This is the new build system for the various wolfSSL products' manuals, please see the READMEs each directory for more information.
5+
* Has a possible code review process
6+
* Can automatically generate PDF and HTML output
7+
* Has cross links between parts of the documentation
8+
* Has links to the required API parts
69

7-
## Site styling
10+
## Building Documentation
811

9-
To generate wolfSSL themed html docs, you'll need the mkdocs-material submodule. To get the repo, you can either:
12+
To build the documentation you will need Docker running on your system. In this documentation root directory run `make` to build the documentation for every project which will output in a `build` subdirectory of this root directory (**note**: on some systems you may need to use `sudo` before `make`). You can also build individual project manuals by doing:
1013

11-
1. Clone the documentation repo recursively.
14+
* `make wolfssl`
15+
* `make wolfssh`
16+
* `make wolfboot`
17+
* `make wolfclu`
18+
* `make wolfcrypt-jni`
19+
* `make wolfmqtt`
20+
* `make wolfsentry`
21+
* `make wolfssl-jni`
22+
* `make wolftpm`
1223

13-
`git clone --recursive <repo url>`
24+
## Contributing
1425

15-
2. Update the submodules, if documentation repo is already cloned.
26+
There is a [CONTRIBUTING.md](CONTRIBUTING.md) document which outlines how to add manuals to the tree.
1627

17-
`git submodule update --recursive`
28+
## Building without Docker
1829

19-
Then just run `make html` for the desired manual.
30+
### Pre-requisites
31+
32+
If you are not building using the Docker build system above you can build using Ubuntu, this will require around 3GB of packages to be installed:
33+
34+
```sh
35+
sudo apt install pandoc texlive-full mkdocs doxygen
36+
```
37+
38+
You also need Doxybook2 installed which can be found at: <https://github.com/matusnovak/doxybook2>. Unfortunately there is no package for this. Installation instructions can be found at: <https://github.com/matusnovak/doxybook2#Install>
39+
40+
If Doxybook2 is installed in a non-stardard path you can use the environment variable `DOXYBOOK_PATH` to set it.
41+
42+
### Building
43+
44+
When in each manual directory to build the PDF:
45+
46+
```sh
47+
make pdf
48+
```
49+
50+
To build the HTML:
51+
52+
```sh
53+
make html
54+
```
55+
56+
To build both:
57+
58+
```sh
59+
make
60+
```
61+
62+
To run a local HTML server (HTML is built to a temporary area for this):
63+
64+
```sh
65+
make serve
66+
```

wolfBoot/README.md

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

wolfCLU/README.md

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

wolfCrypt-JNI/README.md

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

wolfMQTT/README.md

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

0 commit comments

Comments
 (0)