Skip to content

Commit 4b2f9d4

Browse files
authored
Merge pull request #1186 from bact/update-build-doc
Update build doc for new spec-parser options
2 parents 484da84 + 3ff6fcd commit 4b2f9d4

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

build.md

+40-40
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
2+
SPDX-FileType: DOCUMENTATION
23
SPDX-License-Identifier: Community-Spec-1.0
3-
SPDX-FileCopyrightText: Copyright 2024 The SPDX Contributors
44
---
55

66
# Building the specification website
77

8-
The specification website building flow looks like this:
8+
You may want to build the specification website locally to test your additions
9+
and edits and review if they render as intended.
910

1011
```text
1112
+-------------------+
@@ -28,7 +29,7 @@ The specification website building flow looks like this:
2829
| +- mkdocs.yml |
2930
+-------------------+
3031
|
31-
mkdocs
32+
MkDocs
3233
|
3334
v
3435
+-------------------+
@@ -40,6 +41,19 @@ The specification website building flow looks like this:
4041
+-------------------+
4142
```
4243

44+
## Table of contents
45+
46+
1. [Prerequisites](#1-prerequisites)
47+
1. [Getting input files](#2-getting-input-files)
48+
1. [Processing model files (Markdown and RDF)](#3-processing-model-files-markdown-and-rdf)
49+
50+
- [Generating model files with spec-parser](#31-generating-model-files-with-spec-parser)
51+
- [Generating a complete MkDocs configuration file](#32-generating-a-complete-mkdocs-configuration-file)
52+
53+
1. [Building HTML](#4-building-html)
54+
1. [Configuring the website](#5-configuring-the-website)
55+
1. [Specification versions on spdx.github.io](#6-specification-versions-on-spdxgithubio)
56+
4357
## 1. Prerequisites
4458

4559
Apart from Git and Python, you have to have [MkDocs](http://mkdocs.org)
@@ -83,67 +97,53 @@ pip3 install -r spec-parser/requirements.txt
8397
*(e.g., chapters and annexes), you can skip to [step 4](#4-building-html).*
8498

8599
Model files in `spdx/spdx-3-model` repository are written in a constrained
86-
Markdown format, with a limited set of allowed headings.
100+
Markdown format, with [a predefined set of section headings][format].
87101
The `spec-parser` processes these model files to generate both ontology files
88102
and final Markdown files suitable for MkDocs.
89103

90104
The `spec-parser` also performs automatic formatting on the resulting Markdown
91105
files. For instance, it converts a list under the "Properties" heading into a
92106
table.
93107

108+
[format]: https://github.com/spdx/spdx-3-model/blob/develop/docs/format.md
109+
94110
### 3.1 Generating model files with spec-parser
95111

96112
To verify the formatting of pre-processed model files and
97113
prepare them for MkDocs, run the following command:
98114

99115
```shell
100-
python3 spec-parser/main.py spdx-3-model/model parser_output
116+
python3 spec-parser/main.py \
117+
--generate-mkdocs --output-mkdocs spdx-spec/docs/model/ \
118+
spdx-3-model/model/
101119
```
102120

103-
*(If `parser_output` already exists, the `spec-parser` will not overwrite it.)*
104-
105-
The command will create files in the `parser_output` directory.
106-
Among its subdirectories, we're particularly interested in:
107-
108-
- `parser_output/mkdocs` - Processed Markdown files for MkDocs:
109-
These files (`.md` extension) are located in various
110-
subdirectories and are intended for processing by MkDocs in the next step.
111-
- `parser_output/rdf` - Ontology (RDF) files:
112-
These files (`spdx-context.jsonld`, `spdx-model.json-ld`, `spdx-model.n3`,
113-
`spdx-model.pretty-xml`,`spdx-model.ttl`, `spdx-model.xml`, etc.)
114-
are ready for immediate use.
115-
116-
- `parser_output/mkdocs`: Processed Markdown files (`.md`) for MkDocs.
117-
These files will be used by MkDocs in the next step.
118-
- `parser_output/rdf`: Ontology (RDF) files, including
119-
`spdx-context.jsonld`, `spdx-model.json-ld`, `spdx-model.ttl`, etc.
120-
These files are ready for immediate use.
121-
122-
Additionally, a `parser_output/model-files.yml` file will be generated.
123-
It contains a list of the files within `parser_output/mkdocs`
124-
and will be used for MkDocs configuration later.
125-
126-
### 3.2 Copying the generated files
121+
The command will instruct the spec-parser to read the input from
122+
`spdx-3-model/model/` and generate processed Markdown files (`.md`),
123+
placing them in the `spdx-spec/docs/model/` directory.
124+
These files will then be used by MkDocs.
127125

128-
Copy the processed Markdown files and ontology files to the `docs/` directory:
126+
An `spdx-spec/docs/model/model-files.yml` file will also be generated.
127+
This file contains a list of the files within `spdx-spec/docs/model/`
128+
and will be used later for MkDocs configuration.
129+
We will move this `model-files.yml` file to the `spdx-spec/` directory
130+
for subsequent use:
129131

130132
```shell
131-
mkdir -p spdx-spec/docs/model
132-
mkdir -p spdx-spec/docs/rdf
133-
cp -R parser_output/mkdocs/* spdx-spec/docs/model
134-
cp -R parser_output/rdf/* spdx-spec/docs/rdf
133+
mv spdx-spec/docs/model/model-files.yml spdx-spec/
135134
```
136135

137-
### 3.3 Generate a complete MkDocs configuration file
136+
### 3.2 Generating a complete MkDocs configuration file
138137

139138
To ensure MkDocs recognizes the new Markdown files,
140-
insert the model file list from `parser_output/model-files.yml`
141-
into the MkDocs configuration file in `spdx-spec/mkdocs.yml`.
139+
insert the model file list from `model-files.yml`
140+
into the MkDocs configuration file in `spdx-spec/mkdocs.yml`,
141+
by using this command:
142142

143143
```shell
144144
spdx-spec/bin/make-mkdocs-config.sh \
145145
-b spdx-spec/mkdocs.yml \
146-
-m parser_output/model-files.yml \
146+
-m spdx-spec/model-files.yml \
147147
-f spdx-spec/mkdocs-full.yml
148148
```
149149

@@ -156,7 +156,7 @@ we will use MkDocs to assemble them into a website.
156156

157157
*Note: all the commands below use the configuration file*
158158
*with the model file list, `mkdocs-full.yml`,*
159-
*generated in [step 3.3](#33-generate-a-complete-mkdocs-configuration-file).*
159+
*generated in [step 3.2](#32-generating-a-complete-mkdocs-configuration-file).*
160160
*If you only want to review the non-model part of the specification*
161161
*(have skipped step 3), please use `mkdocs.yml` instead.*
162162

@@ -193,7 +193,7 @@ section. The order of filenames in this section determines the order of the
193193
page in the navigation bar.
194194

195195
After you have modified the configuration file, you may need to rerun
196-
[step 3.3](#33-generate-a-complete-mkdocs-configuration-file)
196+
[step 3.2](#32-generating-a-complete-mkdocs-configuration-file)
197197
to incorporate the changes into the complete configuration file.
198198

199199
## 6. Specification versions on spdx.github.io

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ nav:
4444
- '4. Terms and definitions': terms-and-definitions.md
4545
- '5. Conformance': conformance.md
4646
- '6. Model and serializations': serializations.md
47-
- model: # __MODEL_PLACEHOLDER__, to be replaced by content from mkdocs-files.yml. Please do not edit this line.
47+
- model: # __MODEL_PLACEHOLDER__, to be replaced by content from model-files.yml. Please do not edit this line.
4848
- "__MODEL_PLACEHOLDER__": "https://example.com" # allows mkdocs.yml to be build/tested without full model list. Please do not edit this line.
4949
- annexes:
5050
- 'A. RDF model definition and diagrams': annexes/rdf-model.md

0 commit comments

Comments
 (0)