|
| 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  |
| 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. |
0 commit comments