Skip to content

Commit 4367da9

Browse files
rene-zededaeriknordmark
authored andcommitted
docs: Add support to readthedocs.io
Add support to mkdocs and readthedocs.io in order to build EVE's documentation through mkdocs and allow to publish it at readthedocs.io. Document sources (.md, .txt, etc) are located through the whole repository. Unfortunately, mkdocs doesn't allow to keep the configuration file along with document sources, so this commit adds a python script which reassembles the repository's tree only with documentation sources and related files, such as figures (.png, .svg). Additionally, it changes all relative links that point to some other file in the repository, such as .go and .sh files, with the full URL that will point to Github EVE's repository. The documentation can be also built locally, through the following commands: python3 docs/mkdocs/prepare_mkdocs.py \ dist/docs-src \ "https://github.com/lf-edge/eve/blob/master" cp docs/mkdocs/mkdocs.yml . mkdocs build Documentation files will be built at dist/docs-src and the links for source files throughout the documentation will point to master branch. To visualize the documentation through a local web server, use: mkdocs serve And access it through the URL: http://127.0.0.1:8000/projects/eve/ Signed-off-by: Renê de Souza Pinto <[email protected]>
1 parent 252d3cb commit 4367da9

File tree

5 files changed

+343
-0
lines changed

5 files changed

+343
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ images/*.yml
66
.go/
77
tags
88
tmp/
9+
mkdocs.yml

.readthedocs.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
version: 2
3+
build:
4+
os: "ubuntu-20.04"
5+
tools:
6+
python: "3.10"
7+
jobs:
8+
post_checkout:
9+
- python3 docs/mkdocs/prepare_mkdocs.py dist/docs-src "https://github.com/lf-edge/eve/blob/master"
10+
- cp docs/mkdocs/mkdocs.yml ./
11+
mkdocs:
12+
configuration: mkdocs.yml
13+
fail_on_warning: false
14+
python:
15+
install:
16+
- requirements: docs/mkdocs/requirements.txt

docs/mkdocs/mkdocs.yml

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
---
2+
site_name: EVE-OS
3+
site_url: https://www.lfedge.org/projects/eve/
4+
repo_name: GitHub
5+
repo_url: https://github.com/lf-edge/eve
6+
docs_dir: dist/docs-src/
7+
site_dir: dist/doc/
8+
plugins:
9+
- search:
10+
indexing: 'full'
11+
theme:
12+
name: readthedocs
13+
highlightjs: true
14+
hljs_languages:
15+
- yaml
16+
- rust
17+
extra:
18+
version: 2.0
19+
nav:
20+
- Introduction: 'docs/README.md'
21+
- 'Building EVE': 'docs/BUILD.md'
22+
- 'EVE Configuration': 'docs/CONFIG.md'
23+
- 'BIOS and Firmware management with EVE': 'docs/BIOS-FIRMWARE.md'
24+
- 'Deploying EVE-OS': 'docs/DEPLOYMENT.md'
25+
- 'Booting EVE': 'docs/BOOTING.md'
26+
- 'Device Connectivity': 'docs/DEVICE-CONNECTIVITY.md'
27+
- Communications: 'docs/COMMS.md'
28+
- Registration: 'docs/REGISTRATION.md'
29+
- 'Update base image': 'docs/BASEIMAGE-UPDATE.md'
30+
- Build-tools: 'build-tools/ver-update/README.md'
31+
- 'Direct support of OCI containers': 'docs/CONTAINERS.md'
32+
- 'Edge Containers': 'docs/ECOS.md'
33+
- 'Edge-View Containers API': 'docs/EDGEVIEW-CONTAINER-API.md'
34+
- Hypervisors: 'docs/HYPERVISORS.md'
35+
- IPC: 'docs/IPC.md'
36+
- 'Keys and Certificates': 'docs/KEYS-AND-CERTS.md'
37+
- 'LED indication': 'docs/LED-INDICATION.md'
38+
- Wireless: 'docs/WIRELESS.md'
39+
- Tasks: 'docs/TASKS.md'
40+
- Upstreaming: 'docs/UPSTREAMING.md'
41+
- 'Bringing EVE up on a new CPU architecture': 'docs/PORTING.md'
42+
- 'Bringing EVE up on new Hardware': 'docs/HARDWARE-BRINGUP.md'
43+
- 'Hardware model description and testing': 'docs/HARDWARE-MODEL.md'
44+
- Cleanup: 'docs/CLEANUP.md'
45+
- 'Configuration properties': 'docs/CONFIG-PROPERTIES.md'
46+
- CI-CD: 'docs/CI-CD.md'
47+
- FAQ: 'docs/FAQ.md'
48+
- Networking:
49+
- 'Network ACLS': 'docs/NETWORK-ACLS.md'
50+
- 'Network Models': 'docs/NETWORK-MODELS.md'
51+
- 'ECO Initialization':
52+
- Initialization: 'docs/ECO-INIT.md'
53+
- 'ECO Metadata': 'docs/ECO-METADATA.md'
54+
- Logging:
55+
- Introduction: 'docs/LOGGING.md'
56+
- 'Log levels': 'docs/LOG-LEVELS.md'
57+
- Security:
58+
- Information: 'docs/SECURITY.md'
59+
- 'Object level encryption': 'docs/OBJECT-LEVEL-ENCRYPTION.md'
60+
- 'Fault injection': 'docs/FAULT-INJECTION.md'
61+
- Storage:
62+
- 'RAID configuration': 'docs/STORAGE-RAID-CONFIGURATION.md'
63+
- ZFS: 'docs/ZFS.md'
64+
- Boards:
65+
- 'NVIDIA Jetson': 'boards/nvidia/jetson/README.md'
66+
- Debugging:
67+
- Information: 'pkg/debug/abuild/README.md'
68+
- Debugging: 'docs/DEBUGGING.md'
69+
- API:
70+
- Information: 'api/README.md'
71+
- V1: 'api/APIv1.md'
72+
- V2: 'api/APIv2.md'
73+
- 'Object signing': 'api/OBJECT-SIGNING.md'
74+
- Profile: 'api/PROFILE.md'
75+
- 'GO Info': 'api/go/README.md'
76+
- Tests:
77+
- app: 'tests/eden/app/README.md'
78+
- eclient: 'tests/eden/eclient/README.md'
79+
- escript: 'tests/eden/escript/README.md'
80+
- flir: 'tests/eden/flir/README.md'
81+
- 'Hardware reboot': 'tests/eden/hardware_reboot/README.md'
82+
- 'I/O performance': 'tests/eden/io_performance/README.md'
83+
- lim: 'tests/eden/lim/README.md'
84+
- Network: 'tests/eden/network/README.md'
85+
- Phoronix: 'tests/eden/phoronix/README.md'
86+
- Reboot: 'tests/eden/reboot/README.md'
87+
- Registry: 'tests/eden/registry/README.md'
88+
- Volume: 'tests/eden/volume/README.md'
89+
- Libs:
90+
- depgraph: 'libs/depgraph/README.md'
91+
- zedUpload: 'libs/zedUpload/README.md'
92+
- reconciler: 'libs/reconciler/README.md'
93+
- EdgeView:
94+
- Information: 'pkg/edgeview/README.md'
95+
- Newlog:
96+
- ipinfo: 'pkg/newlog/vendor/github.com/eriknordmark/ipinfo/README.md'
97+
- 'go.uuid': 'pkg/newlog/vendor/github.com/satori/go.uuid/README.md'
98+
- netdns: 'pkg/newlog/vendor/github.com/vishvananda/netns/README.md'
99+
- unix: 'pkg/newlog/vendor/golang.org/x/sys/unix/README.md'
100+
- fsnotify: 'pkg/newlog/vendor/github.com/fsnotify/fsnotify/README.md'
101+
- logrus: 'pkg/newlog/vendor/github.com/sirupsen/logrus/README.md'
102+
- Pillar:
103+
- Introduction: 'pkg/pillar/README.md'
104+
- Documentation: 'pkg/pillar/docs/README.md'
105+
- containerd: 'pkg/pillar/containerd/README.md'
106+
- domainmgr: 'pkg/pillar/docs/domainmgr.md'
107+
- NIM: 'pkg/pillar/docs/nim.md'
108+
- 'Radio silence': 'pkg/pillar/docs/radio-silence.md'
109+
- tpmmgr: 'pkg/pillar/docs/tpmmgr.md'
110+
- vaultmgr: 'pkg/pillar/docs/vaultmgr.md'
111+
- volumemgr: 'pkg/pillar/docs/volumemgr.md'
112+
- zedmanager: 'pkg/pillar/docs/zedmanager.md'
113+
- zedrouter: 'pkg/pillar/docs/zedrouter.md'
114+
- zedUpload: 'pkg/pillar/vendor/github.com/lf-edge/eve/libs/zedUpload/README.md'
115+
- go-ieproxy: 'pkg/pillar/vendor/github.com/mattn/go-ieproxy/README.md'
116+
- dns: 'pkg/pillar/vendor/github.com/miekg/dns/README.md'
117+
- go-homedir: 'pkg/pillar/vendor/github.com/mitchellh/go-homedir/README.md'
118+
- locker: 'pkg/pillar/vendor/github.com/moby/locker/README.md'
119+
- term: 'pkg/pillar/vendor/github.com/moby/term/README.md'
120+
- aec: 'pkg/pillar/vendor/github.com/morikuni/aec/README.md'
121+
- go-connections: 'pkg/pillar/vendor/github.com/docker/go-connections/sockets/README.md'
122+
- Azure: 'pkg/pillar/vendor/github.com/Azure/go-ansiterm/README.md'
123+
- Focinfi: 'pkg/pillar/vendor/github.com/Focinfi/go-dns-resolver/README.md'
124+
- go-winio: 'pkg/pillar/vendor/github.com/Microsoft/go-winio/README.md'
125+
- hcsshim: 'pkg/pillar/vendor/github.com/Microsoft/hcsshim/README.md'
126+
- wmi: 'pkg/pillar/vendor/github.com/StackExchange/wmi/README.md'
127+
- godmi: 'pkg/pillar/vendor/github.com/VictorLowther/godmi/README.md'
128+
- smart.go: 'pkg/pillar/vendor/github.com/anatol/smart.go/README.md'
129+
- backoff: 'pkg/pillar/vendor/github.com/cenkalti/backoff/README.md'
130+
- eve-tpm2-tools: 'pkg/pillar/vendor/github.com/cshari-zededa/eve-tpm2-tools/eventlog/README.md'
131+
- tpm2: 'pkg/pillar/vendor/github.com/google/go-tpm/tpm2/README.md'
132+
- gax-go: 'pkg/pillar/vendor/github.com/googleapis/gax-go/v2/apierror/internal/proto/README.md'
133+
- mux: 'pkg/pillar/vendor/github.com/gorilla/mux/README.md'
134+
- websocket: 'pkg/pillar/vendor/github.com/gorilla/websocket/README.md'
135+
- zerconf: 'pkg/pillar/vendor/github.com/grandcat/zeroconf/README.md'
136+
- gopac: 'pkg/pillar/vendor/github.com/jackwakefield/gopac/README.md'
137+
- pcidb: 'pkg/pillar/vendor/github.com/jaypipes/pcidb/README.md'
138+
- go-jmespath: 'pkg/pillar/vendor/github.com/jmespath/go-jmespath/README.md'
139+
- go-pcap: 'pkg/pillar/vendor/github.com/packetcap/go-pcap/README.md'
140+
- errors: 'pkg/pillar/vendor/github.com/pkg/errors/README.md'
141+
- go.uuid: 'pkg/pillar/vendor/github.com/satori/go.uuid/README.md'
142+
- w32: 'pkg/pillar/vendor/github.com/shirou/w32/README.md'
143+
- go-fastping: 'pkg/pillar/vendor/github.com/tatsushid/go-fastping/README.md'
144+
- netns: 'pkg/pillar/vendor/github.com/vishvananda/netns/README.md'
145+
- plist: 'pkg/pillar/vendor/howett.net/plist/README.md'
146+
- prometheus: 'pkg/pillar/vendor/github.com/prometheus/client_golang/prometheus/README.md'
147+
- unix: 'pkg/pillar/vendor/golang.org/x/sys/unix/README.md'
148+
- ipinfo: 'pkg/pillar/vendor/github.com/eriknordmark/ipinfo/README.md'
149+
- cloud.google.com: 'pkg/pillar/vendor/cloud.google.com/go/README.md'
150+
- 'cloud.google.com/Security': 'pkg/pillar/vendor/cloud.google.com/go/SECURITY.md'
151+
- 'cloud.google.com/Testing': 'pkg/pillar/vendor/cloud.google.com/go/testing.md'
152+
- 'cloud.google.com/internal': 'pkg/pillar/vendor/cloud.google.com/go/internal/README.md'
153+
- 'cloud.google.com/IAM': 'pkg/pillar/vendor/cloud.google.com/go/iam/README.md'
154+
- 'cloud.google.com/Storage': 'pkg/pillar/vendor/cloud.google.com/go/storage/README.md'
155+
- go-libzfs: 'pkg/pillar/vendor/github.com/bicomsystems/go-libzfs/README.md'
156+
- xxhash: 'pkg/pillar/vendor/github.com/cespare/xxhash/v2/README.md'
157+
- containerd: 'pkg/pillar/vendor/github.com/containerd/containerd/README.md'
158+
- 'containerd/sysx': 'pkg/pillar/vendor/github.com/containerd/continuity/sysx/README.md'
159+
- 'containerd/fifo': 'pkg/pillar/vendor/github.com/containerd/fifo/readme.md'
160+
- 'containerd/ttrpc': 'pkg/pillar/vendor/github.com/containerd/ttrpc/README.md'
161+
- 'containerd/typeurl': 'pkg/pillar/vendor/github.com/containerd/typeurl/README.md'
162+
- go-libvirt: 'pkg/pillar/vendor/github.com/digitalocean/go-libvirt/README.md'
163+
- go-qemu: 'pkg/pillar/vendor/github.com/digitalocean/go-qemu/qmp/README.md'
164+
- 'docker/client/': 'pkg/pillar/vendor/github.com/docker/docker/client/README.md'
165+
- 'docker/socket/': 'pkg/pillar/vendor/github.com/docker/docker/pkg/stringid/README.md'
166+
- distribution: 'pkg/pillar/vendor/github.com/docker/distribution/README.md'
167+
- API: 'pkg/pillar/vendor/github.com/docker/docker/api/README.md'
168+
- 'API versions': 'pkg/pillar/vendor/github.com/docker/docker/api/types/versions/README.md'
169+
- go-events: 'pkg/pillar/vendor/github.com/docker/go-events/README.md'
170+
- go-metrics: 'pkg/pillar/vendor/github.com/docker/go-metrics/README.md'
171+
- go-units: 'pkg/pillar/vendor/github.com/docker/go-units/README.md'
172+
- fsnotify: 'pkg/pillar/vendor/github.com/fsnotify/fsnotify/README.md'
173+
- yaml: 'pkg/pillar/vendor/github.com/ghodss/yaml/README.md'
174+
- go-ole: 'pkg/pillar/vendor/github.com/go-ole/go-ole/README.md'
175+
- jwt: 'pkg/pillar/vendor/github.com/golang-jwt/jwt/README.md'
176+
- 'go-containerregistry/authn': 'pkg/pillar/vendor/github.com/google/go-containerregistry/pkg/authn/README.md'
177+
- 'go-containerregistry/name': 'pkg/pillar/vendor/github.com/google/go-containerregistry/pkg/name/README.md'
178+
- 'go-containerregistry/partial': 'pkg/pillar/vendor/github.com/google/go-containerregistry/pkg/v1/partial/README.md'
179+
- 'go-containerregistry/remote': 'pkg/pillar/vendor/github.com/google/go-containerregistry/pkg/v1/remote/README.md'
180+
- 'go-containerregistry/transport': 'pkg/pillar/vendor/github.com/google/go-containerregistry/pkg/v1/remote/transport/README.md'
181+
- 'go-containerregistry/stream': 'pkg/pillar/vendor/github.com/google/go-containerregistry/pkg/v1/stream/README.md'
182+
- 'go-containerregistry/tarball': 'pkg/pillar/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/README.md'
183+
- gopacket: 'pkg/pillar/vendor/github.com/google/gopacket/README.md'
184+
- uuid: 'pkg/pillar/vendor/github.com/google/uuid/README.md'
185+
- ghw: 'pkg/pillar/vendor/github.com/jaypipes/ghw/README.md'
186+
- 'compress': 'pkg/pillar/vendor/github.com/klauspost/compress/README.md'
187+
- 'compress/fse': 'pkg/pillar/vendor/github.com/klauspost/compress/fse/README.md'
188+
- 'compress/huff0': 'pkg/pillar/vendor/github.com/klauspost/compress/huff0/README.md'
189+
- 'compress/zstd': 'pkg/pillar/vendor/github.com/klauspost/compress/zstd/README.md'
190+
- 'compres/xxhash': 'pkg/pillar/vendor/github.com/klauspost/compress/zstd/internal/xxhash/README.md'
191+
- gomega: 'pkg/pillar/vendor/github.com/onsi/gomega/README.md'
192+
- opencontainers: 'pkg/pillar/vendor/github.com/opencontainers/go-digest/README.md'
193+
- 'opencontainers/pwalk': 'pkg/pillar/vendor/github.com/opencontainers/selinux/pkg/pwalk/README.md'
194+
- 'opencontainers/pwalkdir': 'pkg/pillar/vendor/github.com/opencontainers/selinux/pkg/pwalkdir/README.md'
195+
- sftp: 'pkg/pillar/vendor/github.com/pkg/sftp/README.md'
196+
- procfs: 'pkg/pillar/vendor/github.com/prometheus/procfs/README.md'
197+
- otto: 'pkg/pillar/vendor/github.com/robertkrimen/otto/README.markdown'
198+
- 'otto/Design': 'pkg/pillar/vendor/github.com/robertkrimen/otto/DESIGN.markdown'
199+
- 'otto/ast': 'pkg/pillar/vendor/github.com/robertkrimen/otto/ast/README.markdown'
200+
- 'otto/file': 'pkg/pillar/vendor/github.com/robertkrimen/otto/file/README.markdown'
201+
- 'otto/parser': 'pkg/pillar/vendor/github.com/robertkrimen/otto/parser/README.markdown'
202+
- 'otto/registry': 'pkg/pillar/vendor/github.com/robertkrimen/otto/registry/README.markdown'
203+
- 'otto/token': 'pkg/pillar/vendor/github.com/robertkrimen/otto/token/README.markdown'
204+
- logrus: 'pkg/pillar/vendor/github.com/sirupsen/logrus/README.md'
205+
- netlink: 'pkg/pillar/vendor/github.com/vishvananda/netlink/README.md'
206+
- go.opencensus.io: 'pkg/pillar/vendor/go.opencensus.io/README.md'
207+
- oauth2: 'pkg/pillar/vendor/golang.org/x/oauth2/README.md'
208+
- appengine: 'pkg/pillar/vendor/google.golang.org/appengine/README.md'
209+
- grpc: 'pkg/pillar/vendor/google.golang.org/grpc/README.md'
210+
- sourcemap: 'pkg/pillar/vendor/gopkg.in/sourcemap.v1/README.md'
211+
- yaml V2: 'pkg/pillar/vendor/gopkg.in/yaml.v2/README.md'
212+
- yaml V3: 'pkg/pillar/vendor/gopkg.in/yaml.v3/README.md'
213+
- Hypervisors:
214+
- Xen: 'pkg/xen/README.md'
215+
- Miscellaneous:
216+
- RNGD: 'pkg/rngd/cmd/rngd/vendor/golang.org/x/sys/unix/README.md'
217+
- U-boot: 'pkg/u-boot/README.md'
218+
- UEFI: 'pkg/uefi/rpi/README.md'
219+
- WLAN: 'pkg/wlan/FIXME.md'

docs/mkdocs/prepare_mkdocs.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""This script prepares documentation files for mkdocs."""
5+
6+
import os
7+
import sys
8+
import shutil
9+
import re
10+
11+
# Output directory for document sources
12+
if len(sys.argv) <= 2:
13+
print("Use: python", sys.argv[0], "<output-directory> <repository-url>")
14+
sys.exit(1)
15+
else:
16+
outdir = sys.argv[1]
17+
repourl = sys.argv[2]
18+
19+
# Regex
20+
reLinks = re.compile(r'\[([^\]]+)\]\(([^)]+)\)')
21+
reURL = re.compile(r'[A-Za-z0-9]+://[A-Za-z0-9%-_]+(/[A-Za-z0-9%-_])*(#|\\?)[A-Za-z0-9%-_&=]*')
22+
reMAIL = re.compile(r'mailto:.*')
23+
reANCHOR = re.compile(r'^#.*')
24+
25+
# All extensions for document sources
26+
docsources = [".md", ".markdown", ".txt", ".png", ".svg", ".gif", ".jpg", ".jpeg"]
27+
# Extensions for markdown files
28+
mkdfiles = [".md", ".markdown"]
29+
30+
# Create output directory
31+
os.makedirs(outdir, exist_ok=True)
32+
33+
# Search for all document sources in repository
34+
pwd = os.getcwd()
35+
for root, sub, files in os.walk(pwd):
36+
for f in files:
37+
fstr = os.path.splitext(f)
38+
fext = fstr[len(fstr) - 1]
39+
try:
40+
# Only get files with extensions in the list
41+
ext = docsources.index(fext)
42+
fpath = os.path.join(root, f)
43+
rpath = os.path.relpath(fpath, start=pwd)
44+
45+
# Get directory path from file
46+
dpath = os.path.dirname(rpath)
47+
48+
# Don't look on output directory
49+
if os.path.commonpath([dpath, outdir]) == outdir:
50+
break
51+
52+
# Create corresponding directory
53+
npath = os.path.join(outdir, dpath)
54+
if os.path.isdir(npath) is False:
55+
try:
56+
os.makedirs(npath, exist_ok=True)
57+
except OSError as error:
58+
print(error)
59+
60+
# Destination file
61+
destfile = os.path.join(npath, f)
62+
63+
# Process document source file
64+
try:
65+
sidx = mkdfiles.index(docsources[ext])
66+
with open(fpath, encoding=sys.getdefaultencoding()) as fp:
67+
with open(destfile, "w", encoding=sys.getdefaultencoding()) as fout:
68+
ftxt = fp.read()
69+
70+
# Search for all markdown links in the file
71+
mdlinks = reLinks.findall(ftxt)
72+
73+
for l in mdlinks:
74+
# If the link is not an URL, check if it points to a
75+
# non-document source file. If so, convert it to
76+
# an URL for source code repository
77+
link = l[1].strip()
78+
if reURL.match(link) or reANCHOR.match(link) or reMAIL.match(link):
79+
continue
80+
# Not an URL, remove anchor link (if exist)
81+
flink = re.sub(r'#.*','',link)
82+
83+
try:
84+
# Get file extension of the link
85+
lstr = os.path.splitext(flink)
86+
lext = lstr[len(lstr) - 1]
87+
didx = docsources.index(lext)
88+
# It's a document source, we don't need to process
89+
continue
90+
except ValueError:
91+
# Build the full URL for the link
92+
lrpath = os.path.relpath(fpath, start=pwd)
93+
ldpath = os.path.dirname(lrpath)
94+
lurl = repourl + "/" + ldpath + "/" + flink
95+
# Substitute link with the full URL in the text
96+
ftxt = ftxt.replace("(" + flink, "(" + lurl)
97+
98+
fout.write(ftxt)
99+
fout.close()
100+
fp.close()
101+
except ValueError:
102+
# Not a source file, just copy the file
103+
shutil.copy(fpath, destfile)
104+
finally:
105+
continue

docs/mkdocs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
jinja2<3.1.0
2+
mkdocs==1.3.1

0 commit comments

Comments
 (0)