Merge ~rkratky/ubuntu-governance-docs:update-starter-pack into ubuntu-governance-docs:main

Proposed by Robert Krátký
Status: Merged
Merged at revision: 7d3ad355a2c0f4edd91d9204f1af47e0288f5665
Proposed branch: ~rkratky/ubuntu-governance-docs:update-starter-pack
Merge into: ubuntu-governance-docs:main
Diff against target: 953 lines (+539/-199)
17 files modified
dev/null (+0/-114)
docs/.custom_wordlist.txt (+24/-0)
docs/.gitignore (+15/-4)
docs/.sphinx/.markdownlint.json (+27/-0)
docs/.sphinx/.pre-commit-config.yaml (+23/-0)
docs/.sphinx/.wordlist.txt (+6/-3)
docs/.sphinx/_static/project_specific.css (+0/-0)
docs/.sphinx/_templates/footer.html (+111/-0)
docs/.sphinx/_templates/header.html (+4/-4)
docs/.sphinx/get_vale_conf.py (+34/-7)
docs/.sphinx/metrics/build_metrics.sh (+15/-0)
docs/.sphinx/metrics/source_metrics.sh (+66/-0)
docs/.sphinx/pa11y.json (+1/-1)
docs/.sphinx/requirements.txt (+3/-1)
docs/.sphinx/spellingcheck.yaml (+29/-29)
docs/Makefile (+165/-8)
docs/conf.py (+16/-28)
Reviewer Review Type Date Requested Status
Robie Basak Pending
Review via email: mp+482863@code.launchpad.net

Commit message

Update the Docs Started Pack to latest version

Description of the change

* Merge Makefiles
* Adapt templates and config for Launchpad
* Add new features (metrics, vale linting)
* Remove unused artifacts
* Various small enhancements

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/docs/.custom_wordlist.txt b/docs/.custom_wordlist.txt
2index e69de29..01abb2d 100644
3--- a/docs/.custom_wordlist.txt
4+++ b/docs/.custom_wordlist.txt
5@@ -0,0 +1,24 @@
6+# Leave a blank line at the end of this file to support concatenation
7+cjk
8+cryptographically
9+dvipng
10+fonts
11+freefont
12+github
13+GPG
14+gyre
15+https
16+lang
17+latexmk
18+otf
19+plantuml
20+tex
21+texlive
22+TOC
23+utils
24+WCAG
25+xetex
26+xindy
27+kustom
28+wordlist
29+txt
30diff --git a/docs/.gitignore b/docs/.gitignore
31index da6f688..bf16e0d 100644
32--- a/docs/.gitignore
33+++ b/docs/.gitignore
34@@ -1,14 +1,25 @@
35-/*env*/
36+# Environment
37+*env*/
38 .sphinx/venv/
39+
40+# Sphinx
41 .sphinx/warnings.txt
42 .sphinx/.wordlist.dic
43 .sphinx/.doctrees/
44 .sphinx/node_modules/
45-package*.json
46+
47+# Vale
48+.sphinx/styles/*
49+.sphinx/vale.ini
50+
51+# Build outputs
52 _build
53+
54+# Node.js
55+package*.json
56+
57+# Unrelated cache and config files
58 .DS_Store
59 __pycache__
60 .idea/
61 .vscode/
62-.sphinx/styles/*
63-.sphinx/vale.ini
64\ No newline at end of file
65diff --git a/docs/.sphinx/.markdownlint.json b/docs/.sphinx/.markdownlint.json
66new file mode 100644
67index 0000000..f42753f
68--- /dev/null
69+++ b/docs/.sphinx/.markdownlint.json
70@@ -0,0 +1,27 @@
71+{
72+ "default": false,
73+ "MD003": {
74+ "style": "atx"
75+ },
76+ "MD013": {
77+ "code_blocks": false,
78+ "tables": false,
79+ "stern": true,
80+ "line_length": 150
81+ },
82+ "MD014": true,
83+ "MD018": true,
84+ "MD022": true,
85+ "MD023": true,
86+ "MD026": {
87+ "punctuation": ".,;。,;"
88+ },
89+ "MD031": {
90+ "list_items": false
91+ },
92+ "MD032": true,
93+ "MD035": true,
94+ "MD042": true,
95+ "MD045": true,
96+ "MD052": true
97+}
98\ No newline at end of file
99diff --git a/docs/.sphinx/.pre-commit-config.yaml b/docs/.sphinx/.pre-commit-config.yaml
100new file mode 100644
101index 0000000..07e0b48
102--- /dev/null
103+++ b/docs/.sphinx/.pre-commit-config.yaml
104@@ -0,0 +1,23 @@
105+repos:
106+ - repo: local
107+ hooks:
108+ - id: make-spelling
109+ name: Run make spelling
110+ entry: make -C docs spelling
111+ language: system
112+ pass_filenames: false
113+ files: ^docs/.*\.(rst|md|txt)$
114+
115+ - id: make-linkcheck
116+ name: Run make linkcheck
117+ entry: make -C docs linkcheck
118+ language: system
119+ pass_filenames: false
120+ files: ^docs/.*\.(rst|md|txt)$
121+
122+ - id: make-woke
123+ name: Run make woke
124+ entry: make -C docs woke
125+ language: system
126+ pass_filenames: false
127+ files: ^docs/.*\.(rst|md|txt)$
128diff --git a/docs/.sphinx/.wordlist.txt b/docs/.sphinx/.wordlist.txt
129index fb4137d..be5021a 100644
130--- a/docs/.sphinx/.wordlist.txt
131+++ b/docs/.sphinx/.wordlist.txt
132@@ -1,13 +1,15 @@
133-# This wordlist is from the Sphinx starter pack and should not be
134-# modified. Add any custom terms to .custom_wordlist.txt instead.
135-
136+ACME
137+ACME's
138 addons
139+AGPLv
140 API
141 APIs
142 balancer
143 Charmhub
144 CLI
145+DCO
146 Diátaxis
147+Dqlite
148 dropdown
149 EBS
150 EKS
151@@ -53,6 +55,7 @@ RTD
152 subdirectories
153 subfolders
154 subtree
155+TODO
156 Ubuntu
157 UI
158 UUID
159diff --git a/docs/.sphinx/_static/favicon.png b/docs/.sphinx/_static/favicon.png
160deleted file mode 100644
161index 7f175e4..0000000
162Binary files a/docs/.sphinx/_static/favicon.png and /dev/null differ
163diff --git a/docs/.sphinx/_static/project_specific.css b/docs/.sphinx/_static/project_specific.css
164new file mode 100644
165index 0000000..e69de29
166--- /dev/null
167+++ b/docs/.sphinx/_static/project_specific.css
168diff --git a/docs/.sphinx/_static/tag.png b/docs/.sphinx/_static/tag.png
169deleted file mode 100644
170index f6f6e5a..0000000
171Binary files a/docs/.sphinx/_static/tag.png and /dev/null differ
172diff --git a/docs/.sphinx/_templates/footer.html b/docs/.sphinx/_templates/footer.html
173new file mode 100644
174index 0000000..2d118a8
175--- /dev/null
176+++ b/docs/.sphinx/_templates/footer.html
177@@ -0,0 +1,111 @@
178+{# ru-fu: copied from Furo, with modifications as stated below. Modifications are marked 'mod:'. #}
179+
180+<div class="related-pages">
181+ {# mod: Per-page navigation #}
182+ {% if meta %}
183+ {% if 'sequential_nav' in meta %}
184+ {% set sequential_nav = meta.sequential_nav %}
185+ {% endif %}
186+ {% endif %}
187+ {# mod: Conditional wrappers to control page navigation buttons #}
188+ {% if sequential_nav != "none" -%}
189+ {% if next and (sequential_nav == "next" or sequential_nav == "both") -%}
190+ <a class="next-page" href="{{ next.link }}">
191+ <div class="page-info">
192+ <div class="context">
193+ <span>{{ _("Next") }}</span>
194+ </div>
195+ <div class="title">{{ next.title }}</div>
196+ </div>
197+ <svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
198+ </a>
199+ {%- endif %}
200+ {% if prev and (sequential_nav == "prev" or sequential_nav == "both") -%}
201+ <a class="prev-page" href="{{ prev.link }}">
202+ <svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
203+ <div class="page-info">
204+ <div class="context">
205+ <span>{{ _("Previous") }}</span>
206+ </div>
207+ {% if prev.link == pathto(root_doc) %}
208+ <div class="title">{{ _("Home") }}</div>
209+ {% else %}
210+ <div class="title">{{ prev.title }}</div>
211+ {% endif %}
212+ </div>
213+ </a>
214+ {%- endif %}
215+ {%- endif %}
216+</div>
217+<div class="bottom-of-page">
218+ <div class="left-details">
219+ {%- if show_copyright %}
220+ <div class="copyright">
221+ {%- if hasdoc('copyright') %}
222+ {% trans path=pathto('copyright'), copyright=copyright|e -%}
223+ <a href="{{ path }}">Copyright</a> &#169; {{ copyright }}
224+ {%- endtrans %}
225+ {%- else %}
226+ {% trans copyright=copyright|e -%}
227+ Copyright &#169; {{ copyright }}
228+ {%- endtrans %}
229+ {%- endif %}
230+ </div>
231+ {%- endif %}
232+
233+ {# mod: removed "Made with" #}
234+
235+ {%- if last_updated -%}
236+ <div class="last-updated">
237+ {% trans last_updated=last_updated|e -%}
238+ Last updated on {{ last_updated }}
239+ {%- endtrans -%}
240+ </div>
241+ {%- endif %}
242+
243+ {%- if show_source and has_source and sourcename %}
244+ <div class="show-source">
245+ <a class="muted-link" href="{{ pathto('_sources/' + sourcename, true)|e }}"
246+ rel="nofollow">Show source</a>
247+ </div>
248+ {%- endif %}
249+ </div>
250+ <div class="right-details">
251+
252+ {# mod: replaced RTD icons with our links #}
253+
254+ {% if discourse %}
255+ <div class="ask-discourse">
256+ <a class="muted-link" href="{{ discourse }}">Ask a question on Discourse</a>
257+ </div>
258+ {% endif %}
259+
260+ {% if irc %}
261+ <div class="ask-mattermost">
262+ <a class="muted-link" href="{{ irc }}">Ask a question on IRC</a>
263+ </div>
264+ {% endif %}
265+
266+ {% if matrix %}
267+ <div class="ask-matrix">
268+ <a class="muted-link" href="{{ matrix }}">Ask a question on Matrix</a>
269+ </div>
270+ {% endif %}
271+
272+ {% if launchpad_url and launchpad_version and launchpad_folder %}
273+
274+ {% if launchpad_issues %}
275+ <div class="issue-github">
276+ <a class="muted-link" href="{{ launchpad_issues }}">Open a Launchpad issue for this documentation</a>
277+ </div>
278+ {% endif %}
279+
280+ <div class="edit-github">
281+ <a class="muted-link" href="{{ launchpad_url }}/tree{{ launchpad_folder }}{{ pagename }}{{ page_source_suffix }}">View this page on Launchpad</a>
282+ </div>
283+ {% endif %}
284+
285+
286+ </div>
287+ </div>
288+</div>
289diff --git a/docs/.sphinx/_templates/header.html b/docs/.sphinx/_templates/header.html
290index 30c52c5..d0ac8e5 100644
291--- a/docs/.sphinx/_templates/header.html
292+++ b/docs/.sphinx/_templates/header.html
293@@ -26,9 +26,9 @@
294 </li>
295 {% endif %}
296
297- {% if mattermost %}
298+ {% if irc %}
299 <li>
300- <a href="{{ mattermost }}" class="p-navigation__sub-link p-dropdown__link">Mattermost</a>
301+ <a href="{{ irc }}" class="p-navigation__sub-link p-dropdown__link">IRC</a>
302 </li>
303 {% endif %}
304
305@@ -38,9 +38,9 @@
306 </li>
307 {% endif %}
308
309- {% if github_url %}
310+ {% if launchpad_url %}
311 <li>
312- <a href="{{ github_url }}" class="p-navigation__sub-link p-dropdown__link">GitHub</a>
313+ <a href="{{ launchpad_url }}" class="p-navigation__sub-link p-dropdown__link">Launchpad</a>
314 </li>
315 {% endif %}
316
317diff --git a/docs/.sphinx/get_vale_conf.py b/docs/.sphinx/get_vale_conf.py
318index 23d8901..cb73a64 100644
319--- a/docs/.sphinx/get_vale_conf.py
320+++ b/docs/.sphinx/get_vale_conf.py
321@@ -3,16 +3,18 @@
322 import requests
323 import os
324
325-DIR=os.getcwd()
326+DIR = os.getcwd()
327
328 def main():
329-
330 if os.path.exists(f"{DIR}/.sphinx/styles/Canonical"):
331 print("Vale directory exists")
332 else:
333 os.makedirs(f"{DIR}/.sphinx/styles/Canonical")
334
335- url = "https://api.github.com/repos/canonical/praecepta/contents/styles/Canonical"
336+ url = (
337+ "https://api.github.com/repos/canonical/praecepta/"
338+ + "contents/styles/Canonical"
339+ )
340 r = requests.get(url)
341 for item in r.json():
342 download = requests.get(item["download_url"])
343@@ -20,22 +22,47 @@ def main():
344 file.write(download.text)
345 file.close()
346
347+ # Update dictionary
348+ if os.path.exists(f"{DIR}/.sphinx/styles/config/dictionaries"):
349+ print("Dictionary directory exists")
350+ else:
351+ os.makedirs(f"{DIR}/.sphinx/styles/config/dictionaries")
352+ url = (
353+ "https://api.github.com/repos/canonical/praecepta/"
354+ + "contents/styles/config/dictionaries"
355+ )
356+ r = requests.get(url)
357+ for item in r.json():
358+ download = requests.get(item["download_url"])
359+ file = open(".sphinx/styles/config/dictionaries/" + item["name"], "w")
360+ file.write(download.text)
361+ file.close()
362+
363 if os.path.exists(f"{DIR}/.sphinx/styles/config/vocabularies/Canonical"):
364 print("Vocab directory exists")
365 else:
366 os.makedirs(f"{DIR}/.sphinx/styles/config/vocabularies/Canonical")
367-
368- url = "https://api.github.com/repos/canonical/praecepta/contents/styles/config/vocabularies/Canonical"
369+
370+ url = (
371+ "https://api.github.com/repos/canonical/praecepta/"
372+ + "contents/styles/config/vocabularies/Canonical"
373+ )
374 r = requests.get(url)
375 for item in r.json():
376 download = requests.get(item["download_url"])
377- file = open(".sphinx/styles/config/vocabularies/Canonical/" + item["name"], "w")
378+ file = open(
379+ ".sphinx/styles/config/vocabularies/Canonical/" + item["name"],
380+ "w"
381+ )
382 file.write(download.text)
383 file.close()
384- config = requests.get("https://raw.githubusercontent.com/canonical/praecepta/main/vale.ini")
385+ config = requests.get(
386+ "https://raw.githubusercontent.com/canonical/praecepta/main/vale.ini"
387+ )
388 file = open(".sphinx/vale.ini", "w")
389 file.write(config.text)
390 file.close()
391
392+
393 if __name__ == "__main__":
394 main()
395diff --git a/docs/.sphinx/metrics/build_metrics.sh b/docs/.sphinx/metrics/build_metrics.sh
396new file mode 100755
397index 0000000..bd1ff1c
398--- /dev/null
399+++ b/docs/.sphinx/metrics/build_metrics.sh
400@@ -0,0 +1,15 @@
401+#!/bin/bash
402+# shellcheck disable=all
403+
404+links=0
405+images=0
406+
407+# count number of links
408+links=$(find . -type d -path './.sphinx' -prune -o -name '*.html' -exec cat {} + | grep -o "<a " | wc -l)
409+# count number of images
410+images=$(find . -type d -path './.sphinx' -prune -o -name '*.html' -exec cat {} + | grep -o "<img " | wc -l)
411+
412+# summarise latest metrics
413+echo "Summarising metrics for build files (.html)..."
414+echo -e "\tlinks: $links"
415+echo -e "\timages: $images"
416diff --git a/docs/.sphinx/metrics/source_metrics.sh b/docs/.sphinx/metrics/source_metrics.sh
417new file mode 100755
418index 0000000..07147d6
419--- /dev/null
420+++ b/docs/.sphinx/metrics/source_metrics.sh
421@@ -0,0 +1,66 @@
422+#!/bin/bash
423+# shellcheck disable=all
424+
425+VENV=".sphinx/venv/bin/activate"
426+
427+files=0
428+words=0
429+readabilityWords=0
430+readabilitySentences=0
431+readabilitySyllables=0
432+readabilityAverage=0
433+readable=true
434+
435+# measure number of files (.rst and .md), excluding those in .sphinx dir
436+files=$(find . -type d -path './.sphinx' -prune -o -type f \( -name '*.md' -o -name '*.rst' \) -print | wc -l)
437+
438+# calculate metrics only if source files are present
439+if [ "$files" -eq 0 ]; then
440+ echo "There are no source files to calculate metrics"
441+else
442+ # measure raw total number of words, excluding those in .sphinx dir
443+ words=$(find . -type d -path './.sphinx' -prune -o \( -name '*.md' -o -name '*.rst' \) -exec cat {} + | wc -w)
444+
445+ # calculate readability for markdown source files
446+ echo "Activating virtual environment to run vale..."
447+ source "${VENV}"
448+
449+ for file in *.md *.rst; do
450+ if [ -f "$file" ]; then
451+ readabilityWords=$(vale ls-metrics "$file" | grep '"words"' | sed 's/[^0-9]*//g')
452+ readabilitySentences=$(vale ls-metrics "$file" | grep '"sentences"' | sed 's/[^0-9]*//g')
453+ readabilitySyllables=$(vale ls-metrics "$file" | grep '"syllables"' | sed 's/[^0-9]*//g')
454+ fi
455+ done
456+
457+ echo "Deactivating virtual environment..."
458+ deactivate
459+
460+ # calculate mean number of words
461+ if [ "$files" -ge 1 ]; then
462+ meanval=$((readabilityWords / files))
463+ else
464+ meanval=$readabilityWords
465+ fi
466+
467+ readabilityAverage=$(echo "scale=2; 0.39 * ($readabilityWords / $readabilitySentences) + (11.8 * ($readabilitySyllables / $readabilityWords)) - 15.59" | bc)
468+
469+ # cast average to int for comparison
470+ readabilityAverageInt=$(echo "$readabilityAverage / 1" | bc)
471+
472+ # value below 8 is considered readable
473+ if [ "$readabilityAverageInt" -lt 8 ]; then
474+ readable=true
475+ else
476+ readable=false
477+ fi
478+
479+ # summarise latest metrics
480+ echo "Summarising metrics for source files (.md, .rst)..."
481+ echo -e "\ttotal files: $files"
482+ echo -e "\ttotal words (raw): $words"
483+ echo -e "\ttotal words (prose): $readabilityWords"
484+ echo -e "\taverage word count: $meanval"
485+ echo -e "\treadability: $readabilityAverage"
486+ echo -e "\treadable: $readable"
487+fi
488diff --git a/docs/.sphinx/pa11y.json b/docs/.sphinx/pa11y.json
489index 8df0cb9..04dc1e1 100644
490--- a/docs/.sphinx/pa11y.json
491+++ b/docs/.sphinx/pa11y.json
492@@ -6,4 +6,4 @@
493 },
494 "reporter": "cli",
495 "standard": "WCAG2AA"
496-}
497\ No newline at end of file
498+}
499diff --git a/docs/.sphinx/requirements.txt b/docs/.sphinx/requirements.txt
500index c019f17..9ff666c 100644
501--- a/docs/.sphinx/requirements.txt
502+++ b/docs/.sphinx/requirements.txt
503@@ -1,2 +1,4 @@
504-git+https://github.com/canonical/canonical-sphinx@main#egg=canonical-sphinx
505+canonical-sphinx[full]
506 sphinx-autobuild
507+sphinxcontrib-svg2pdfconverter[CairoSVG]
508+sphinx-last-updated-by-git
509diff --git a/docs/.sphinx/spellingcheck.yaml b/docs/.sphinx/spellingcheck.yaml
510index 5f3dbad..9ee9ae7 100644
511--- a/docs/.sphinx/spellingcheck.yaml
512+++ b/docs/.sphinx/spellingcheck.yaml
513@@ -1,30 +1,30 @@
514 matrix:
515-- name: rST files
516- aspell:
517- lang: en
518- d: en_GB
519- dictionary:
520- wordlists:
521- - .sphinx/.wordlist.txt
522- - .custom_wordlist.txt
523- output: .sphinx/.wordlist.dic
524- sources:
525- - _build/**/*.html
526- pipeline:
527- - pyspelling.filters.html:
528- comments: false
529- attributes:
530- - title
531- - alt
532- ignores:
533- - code
534- - pre
535- - spellexception
536- - link
537- - title
538- - div.relatedlinks
539- - strong.command
540- - div.visually-hidden
541- - img
542- - a.p-navigation__link
543- - a.contributor
544+ - name: rST files
545+ aspell:
546+ lang: en
547+ d: en_GB
548+ dictionary:
549+ wordlists:
550+ - .sphinx/.wordlist.txt
551+ - .custom_wordlist.txt
552+ output: .sphinx/.wordlist.dic
553+ sources:
554+ - _build/**/*.html
555+ pipeline:
556+ - pyspelling.filters.html:
557+ comments: false
558+ attributes:
559+ - title
560+ - alt
561+ ignores:
562+ - code
563+ - pre
564+ - spellexception
565+ - link
566+ - title
567+ - div.relatedlinks
568+ - strong.command
569+ - div.visually-hidden
570+ - img
571+ - a.p-navigation__link
572+ - a.contributor
573diff --git a/docs/Makefile b/docs/Makefile
574index a861ba8..b9bdea0 100644
575--- a/docs/Makefile
576+++ b/docs/Makefile
577@@ -1,11 +1,23 @@
578-# This Makefile stub allows you to customize starter pack (SP) targets.
579-# Consider this file as a bridge between your project
580-# and the starter pack's predefined targets that reside in Makefile.sp.
581+# Minimal makefile for Sphinx documentation
582 #
583-# You can add your own, non-SP targets here or override SP targets
584-# to fit your project's needs. For example, you can define and use targets
585-# named "install" or "run", but continue to use SP targets like "sp-install"
586-# or "sp-run" when working on the documentation.
587+# Add your customisation to `Makefile` instead.
588+
589+# You can set these variables from the command line, and also
590+# from the environment for the first two.
591+SPHINXDIR = .sphinx
592+SPHINXOPTS ?= -c . -d $(SPHINXDIR)/.doctrees -j auto
593+SPHINXBUILD ?= $(VENVDIR)/bin/sphinx-build
594+SOURCEDIR = .
595+BUILDDIR = _build
596+VENVDIR = $(SPHINXDIR)/venv
597+PA11Y = $(SPHINXDIR)/node_modules/pa11y/bin/pa11y.js --config $(SPHINXDIR)/pa11y.json
598+VENV = $(VENVDIR)/bin/activate
599+TARGET = *
600+ALLFILES = *.rst **/*.rst
601+METRICSDIR = $(SOURCEDIR)/.sphinx/metrics
602+REQPDFPACKS = latexmk fonts-freefont-otf texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended texlive-font-utils texlive-lang-cjk texlive-xetex plantuml xindy tex-gyre dvipng
603+CONFIRM_SUDO ?= N
604+VALE_CONFIG = $(SPHINXDIR)/vale.ini
605
606 # Put it first so that "make" without argument is like "make help".
607 help:
608@@ -23,8 +35,153 @@ help:
609 "* check accessibility: make pa11y \n" \
610 "* check style guide compliance: make vale \n" \
611 "* check style guide compliance on target: make vale TARGET=* \n" \
612+ "* check metrics for documentation: make allmetrics \n" \
613 "* other possible targets: make <TAB twice> \n" \
614 "------------------------------------------------------------- \n"
615
616+.PHONY: full-help woke-install spellcheck-install pa11y-install install run html \
617+ epub serve clean clean-doc spelling spellcheck linkcheck woke \
618+ allmetrics pa11y pdf-prep-force pdf-prep pdf vale-install vale
619+
620+full-help: $(VENVDIR)
621+ @. $(VENV); $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
622+ @echo "\n\033[1;31mNOTE: This help texts shows unsupported targets!\033[0m"
623+ @echo "Run 'make help' to see supported targets."
624+
625+# If requirements are updated, venv should be rebuilt and timestamped.
626+$(VENVDIR):
627+ python3 -c "import venv" || \
628+ (echo "You must install python3-venv before you can build the documentation."; exit 1)
629+ @echo "... setting up virtualenv"
630+ python3 -m venv $(VENVDIR)
631+ . $(VENV); pip install $(PIPOPTS) --require-virtualenv \
632+ --upgrade -r $(SPHINXDIR)/requirements.txt \
633+ --log $(VENVDIR)/pip_install.log
634+ @test ! -f $(VENVDIR)/pip_list.txt || \
635+ mv $(VENVDIR)/pip_list.txt $(VENVDIR)/pip_list.txt.bak
636+ @. $(VENV); pip list --local --format=freeze > $(VENVDIR)/pip_list.txt
637+ @touch $(VENVDIR)
638+
639+spellcheck-install:
640+ @type aspell >/dev/null 2>&1 || \
641+ { \
642+ echo "Installing system-wide \"aspell\" packages..."; \
643+ confirm_sudo=$(CONFIRM_SUDO); \
644+ if [ "$$confirm_sudo" != "y" ] && [ "$$confirm_sudo" != "Y" ]; then \
645+ read -p "This requires sudo privileges. Proceed? [y/N]: " confirm_sudo; \
646+ fi; \
647+ if [ "$$confirm_sudo" = "y" ] || [ "$$confirm_sudo" = "Y" ]; then \
648+ sudo apt-get install aspell aspell-en; \
649+ else \
650+ echo "Installation cancelled."; \
651+ fi \
652+ }
653+
654+pa11y-install:
655+ @type $(PA11Y) >/dev/null 2>&1 || { \
656+ echo "Installing \"pa11y\" from npm... \n"; \
657+ mkdir -p $(SPHINXDIR)/node_modules/ ; \
658+ npm install --prefix $(SPHINXDIR) pa11y; \
659+ }
660+
661+install: $(VENVDIR)
662+
663+run: install
664+ . $(VENV); $(VENVDIR)/bin/sphinx-autobuild -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
665+
666+# Doesn't depend on $(BUILDDIR) to rebuild properly at every run.
667+html: install
668+ . $(VENV); $(SPHINXBUILD) -W --keep-going -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" -w $(SPHINXDIR)/warnings.txt $(SPHINXOPTS)
669+
670+epub: install
671+ . $(VENV); $(SPHINXBUILD) -b epub "$(SOURCEDIR)" "$(BUILDDIR)" -w $(SPHINXDIR)/warnings.txt $(SPHINXOPTS)
672+
673+serve: html
674+ cd "$(BUILDDIR)"; python3 -m http.server --bind 127.0.0.1 8000
675+
676+clean: clean-doc
677+ @test ! -e "$(VENVDIR)" -o -d "$(VENVDIR)" -a "$(abspath $(VENVDIR))" != "$(VENVDIR)"
678+ rm -rf $(VENVDIR)
679+ rm -rf $(SPHINXDIR)/node_modules/
680+ rm -rf $(SPHINXDIR)/styles
681+ rm -rf $(VALE_CONFIG)
682+
683+clean-doc:
684+ git clean -fx "$(BUILDDIR)"
685+ rm -rf $(SPHINXDIR)/.doctrees
686+
687+spellcheck: spellcheck-install
688+ . $(VENV) ; python3 -m pyspelling -c $(SPHINXDIR)/spellingcheck.yaml -j $(shell nproc)
689+
690+spelling: html spellcheck
691+
692+linkcheck: install
693+ . $(VENV) ; $(SPHINXBUILD) -b linkcheck "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) || { grep --color -F "[broken]" "$(BUILDDIR)/output.txt"; exit 1; }
694+ exit 0
695+
696+pa11y: pa11y-install html
697+ find $(BUILDDIR) -name *.html -print0 | xargs -n 1 -0 $(PA11Y)
698+
699+vale-install: install
700+ @. $(VENV); test -d $(SPHINXDIR)/venv/lib/python*/site-packages/vale || pip install rst2html vale
701+ @. $(VENV); test -f $(VALE_CONFIG) || python3 $(SPHINXDIR)/get_vale_conf.py
702+ @printf '.Name=="Canonical.400-Enforce-inclusive-terms"' > $(SPHINXDIR)/styles/woke.filter
703+ @printf '.Level=="error" and .Name!="Canonical.500-Repeated-words" and .Name!="Canonical.000-US-spellcheck"' > $(SPHINXDIR)/styles/error.filter
704+ @printf '.Name=="Canonical.000-US-spellcheck"' > $(SPHINXDIR)/styles/spelling.filter
705+ @. $(VENV); find $(SPHINXDIR)/venv/lib/python*/site-packages/vale/vale_bin -size 195c -exec vale --config "$(VALE_CONFIG)" $(TARGET) > /dev/null \;
706+
707+woke: vale-install
708+ @cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt
709+ @cat $(SPHINXDIR)/.wordlist.txt $(SOURCEDIR)/.custom_wordlist.txt >> $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt
710+ @printf "Running Vale acceptable term check against $(TARGET). To change target set TARGET= with make command\n"
711+ @. $(VENV); vale --config="$(VALE_CONFIG)" --filter='$(SPHINXDIR)/styles/woke.filter' --glob='*.{md,rst}' $(TARGET) || true
712+ @cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt && rm $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt
713+
714+vale: vale-install
715+ @cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt
716+ @cat $(SPHINXDIR)/.wordlist.txt $(SOURCEDIR)/.custom_wordlist.txt >> $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt
717+ @printf "Running Vale against $(TARGET). To change target set TARGET= with make command\n"
718+ @. $(VENV); vale --config="$(VALE_CONFIG)" --filter='$(SPHINXDIR)/styles/error.filter' --glob='*.{md,rst}' $(TARGET) || true
719+ @cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt && rm $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt
720+
721+vale-spelling: vale-install
722+ @cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt
723+ @cat $(SPHINXDIR)/.wordlist.txt $(SOURCEDIR)/.custom_wordlist.txt >> $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt
724+ @printf "Running Vale against $(TARGET). To change target set TARGET= with make command\n"
725+ @. $(VENV); vale --config="$(VALE_CONFIG)" --filter='$(SPHINXDIR)/styles/spelling.filter' --glob='*.{md,rst}' $(TARGET) || true
726+ @cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt && rm $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt
727+
728+pdf-prep: install
729+ @for packageName in $(REQPDFPACKS); do (dpkg-query -W -f='$${Status}' $$packageName 2>/dev/null | \
730+ grep -c "ok installed" >/dev/null && echo "Package $$packageName is installed") && continue || \
731+ (echo "\nPDF generation requires the installation of the following packages: $(REQPDFPACKS)" && \
732+ echo "" && echo "Run 'sudo make pdf-prep-force' to install these packages" && echo "" && echo \
733+ "Please be aware these packages will be installed to your system") && exit 1 ; done
734+
735+pdf-prep-force:
736+ apt-get update
737+ apt-get upgrade -y
738+ apt-get install --no-install-recommends -y $(REQPDFPACKS) \
739+
740+pdf: pdf-prep
741+ @. $(VENV); sphinx-build -M latexpdf "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
742+ @rm ./$(BUILDDIR)/latex/front-page-light.pdf || true
743+ @rm ./$(BUILDDIR)/latex/normal-page-footer.pdf || true
744+ @find ./$(BUILDDIR)/latex -name "*.pdf" -exec mv -t ./$(BUILDDIR) {} +
745+ @rm -r $(BUILDDIR)/latex
746+ @echo "\nOutput can be found in ./$(BUILDDIR)\n"
747+
748+allmetrics: html
749+ @echo "Recording documentation metrics..."
750+ @echo "Checking for existence of vale..."
751+ . $(VENV)
752+ @. $(VENV); test -d $(SPHINXDIR)/venv/lib/python*/site-packages/vale || pip install vale
753+ @. $(VENV); test -f $(VALE_CONFIG) || python3 $(SPHINXDIR)/get_vale_conf.py
754+ @. $(VENV); find $(SPHINXDIR)/venv/lib/python*/site-packages/vale/vale_bin -size 195c -exec vale --config "$(VALE_CONFIG)" $(TARGET) > /dev/null \;
755+ @eval '$(METRICSDIR)/source_metrics.sh $(PWD)'
756+ @eval '$(METRICSDIR)/build_metrics.sh $(PWD) $(METRICSDIR)'
757+
758+# Catch-all target: route all unknown targets to Sphinx using the new
759+# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
760 %:
761- $(MAKE) -f Makefile.sp sp-$@
762+ . $(VENV); $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
763diff --git a/docs/Makefile.sp b/docs/Makefile.sp
764deleted file mode 100644
765index 80b5141..0000000
766--- a/docs/Makefile.sp
767+++ /dev/null
768@@ -1,114 +0,0 @@
769-# Minimal makefile for Sphinx documentation
770-#
771-# `Makefile.sp` is from the Sphinx starter pack and should not be
772-# modified.
773-# Add your customisation to `Makefile` instead.
774-
775-# You can set these variables from the command line, and also
776-# from the environment for the first two.
777-SPHINXDIR = .sphinx
778-SPHINXOPTS ?= -c . -d $(SPHINXDIR)/.doctrees -j auto
779-SPHINXBUILD ?= $(VENVDIR)/bin/sphinx-build
780-SOURCEDIR = .
781-BUILDDIR = _build
782-VENVDIR = $(SPHINXDIR)/venv
783-PA11Y = $(SPHINXDIR)/node_modules/pa11y/bin/pa11y.js --config $(SPHINXDIR)/pa11y.json
784-VENV = $(VENVDIR)/bin/activate
785-TARGET = *
786-ALLFILES = *.rst **/*.rst
787-
788-.PHONY: sp-full-help sp-woke-install sp-spellcheck-install sp-pa11y-install sp-install sp-run sp-html \
789- sp-epub sp-serve sp-clean sp-clean-doc sp-spelling sp-spellcheck sp-linkcheck sp-woke \
790- sp-pa11y Makefile.sp sp-vale
791-
792-sp-full-help: $(VENVDIR)
793- @. $(VENV); $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
794- @echo "\n\033[1;31mNOTE: This help texts shows unsupported targets!\033[0m"
795- @echo "Run 'make help' to see supported targets."
796-
797-# If requirements are updated, venv should be rebuilt and timestamped.
798-$(VENVDIR):
799- python3 -c "import venv" || \
800- (echo "You must install python3-venv before you can build the documentation."; exit 1)
801- @echo "... setting up virtualenv"
802- python3 -m venv $(VENVDIR)
803- . $(VENV); pip install --require-virtualenv \
804- --upgrade -r $(SPHINXDIR)/requirements.txt \
805- --log $(VENVDIR)/pip_install.log
806- @test ! -f $(VENVDIR)/pip_list.txt || \
807- mv $(VENVDIR)/pip_list.txt $(VENVDIR)/pip_list.txt.bak
808- @. $(VENV); pip list --local --format=freeze > $(VENVDIR)/pip_list.txt
809- @touch $(VENVDIR)
810-
811-sp-woke-install:
812- @type woke >/dev/null 2>&1 || \
813- { echo "Installing \"woke\" snap... \n"; sudo snap install woke; }
814-
815-sp-spellcheck-install:
816- @type aspell >/dev/null 2>&1 || \
817- { echo "Installing aspell... \n"; sudo apt-get install aspell aspell-en; }
818-
819-sp-pa11y-install:
820- @type $(PA11Y) >/dev/null 2>&1 || { \
821- echo "Installing \"pa11y\" from npm... \n"; \
822- mkdir -p $(SPHINXDIR)/node_modules/ ; \
823- npm install --prefix $(SPHINXDIR) pa11y; \
824- }
825-
826-sp-install: $(VENVDIR)
827-
828-sp-run: sp-install
829- . $(VENV); $(VENVDIR)/bin/sphinx-autobuild -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
830-
831-# Doesn't depend on $(BUILDDIR) to rebuild properly at every run.
832-sp-html: sp-install
833- . $(VENV); $(SPHINXBUILD) -W --keep-going -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" -w $(SPHINXDIR)/warnings.txt $(SPHINXOPTS)
834-
835-sp-epub: sp-install
836- . $(VENV); $(SPHINXBUILD) -b epub "$(SOURCEDIR)" "$(BUILDDIR)" -w $(SPHINXDIR)/warnings.txt $(SPHINXOPTS)
837-
838-sp-serve: sp-html
839- cd "$(BUILDDIR)"; python3 -m http.server --bind 127.0.0.1 8000
840-
841-sp-clean: sp-clean-doc
842- @test ! -e "$(VENVDIR)" -o -d "$(VENVDIR)" -a "$(abspath $(VENVDIR))" != "$(VENVDIR)"
843- rm -rf $(VENVDIR)
844- rm -rf $(SPHINXDIR)/node_modules/
845- rm -rf $(SPHINXDIR)/styles
846- rm -rf $(SPHINXDIR)/vale.ini
847-
848-sp-clean-doc:
849- git clean -fx "$(BUILDDIR)"
850- rm -rf $(SPHINXDIR)/.doctrees
851-
852-sp-spellcheck: sp-spellcheck-install
853- . $(VENV) ; python3 -m pyspelling -c $(SPHINXDIR)/spellingcheck.yaml -j $(shell nproc)
854-
855-sp-spelling: sp-html sp-spellcheck
856-
857-sp-linkcheck: sp-install
858- . $(VENV) ; $(SPHINXBUILD) -b linkcheck "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) || { grep --color -F "[broken]" "$(BUILDDIR)/output.txt"; exit 1; }
859- exit 0
860-
861-sp-woke: sp-woke-install
862- woke $(ALLFILES) --exit-1-on-failure \
863- -c https://github.com/canonical/Inclusive-naming/raw/main/config.yml
864-
865-sp-pa11y: sp-pa11y-install sp-html
866- find $(BUILDDIR) -name *.html -print0 | xargs -n 1 -0 $(PA11Y)
867-
868-sp-vale: sp-install
869- @. $(VENV); test -d $(SPHINXDIR)/venv/lib/python*/site-packages/vale || pip install vale
870- @. $(VENV); test -f $(SPHINXDIR)/vale.ini || python3 $(SPHINXDIR)/get_vale_conf.py
871- @. $(VENV); find $(SPHINXDIR)/venv/lib/python*/site-packages/vale/vale_bin -size 195c -exec vale --config "$(SPHINXDIR)/vale.ini" $(TARGET) > /dev/null \;
872- @echo ""
873- @echo "Running Vale against $(TARGET). To change target set TARGET= with make command"
874- @echo ""
875- @. $(VENV); vale --config "$(SPHINXDIR)/vale.ini" --glob='*.{md,txt,rst}' $(TARGET)
876-
877-
878-
879-# Catch-all target: route all unknown targets to Sphinx using the new
880-# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
881-%: Makefile.sp
882- . $(VENV); $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
883diff --git a/docs/conf.py b/docs/conf.py
884index a8b1cd9..c8e6449 100644
885--- a/docs/conf.py
886+++ b/docs/conf.py
887@@ -82,37 +82,24 @@ html_context = {
888 # (use an empty value if you don't want to link)
889 'discourse': 'https://discourse.ubuntu.com',
890
891- # Change to the Mattermost channel you want to link to
892- # (use an empty value if you don't want to link)
893- 'mattermost': '',
894-
895- # Change to the Matrix channel you want to link to
896- # (use an empty value if you don't want to link)
897- 'matrix': '',
898-
899- # Change to the GitHub URL for your project
900- # This is used, for example, to link to the source files and allow creating GitHub issues directly from the documentation.
901- 'github_url': 'https://launchpad.net/~techboard/ubuntu-governance-docs',
902-
903+ # Your IRC channel
904+ "irc": "https://web.libera.chat/gamja/?channels=%23ubuntu-devel",
905+ # Your Matrix channel URL
906+ "matrix": "https://matrix.to/#/#devel:ubuntu.com",
907+ # Your Launchpad URL
908+ "launchpad_url": "https://git.launchpad.net/ubuntu-governance-docs",
909 # Change to the branch for this version of the documentation
910- 'github_version': 'main',
911-
912+ "launchpad_version": "main",
913 # Change to the folder that contains the documentation
914 # (usually "/" or "/docs/")
915- 'github_folder': '/docs/',
916-
917- # Change to an empty value if your GitHub repo doesn't have issues enabled.
918- # This will disable the feedback button and the issue link in the footer.
919- 'github_issues': '',
920-
921+ "launchpad_folder": "/docs/",
922+ # Change to an empty value to disable the issue link in the footer.
923+ "launchpad_issues": "https://bugs.launchpad.net/ubuntu-governance-docs/+filebug",
924 # Controls the existence of Previous / Next buttons at the bottom of pages
925 # Valid options: none, prev, next, both
926- # 'sequential_nav': "none",
927-
928- # Uncomment to disable displaying the contributors for each file.
929- # (You can also limit the time frame for displaying contributors
930- # by setting a "display_contributors_since" variable.)
931- # "display_contributors": False,
932+ "sequential_nav": "both",
933+ # Controls whether to display the contributors for each file
934+ "display_contributors": False,
935
936 }
937
938@@ -178,12 +165,13 @@ myst_enable_extensions = {
939 # If you need more extensions, add them here (in addition to
940 # canonical_sphinx).
941 extensions = [
942- 'canonical_sphinx'
943+ "canonical_sphinx",
944+ "sphinxcontrib.cairosvgconverter",
945+ "sphinx_last_updated_by_git",
946 ]
947
948 # Add files or directories that should be excluded from processing.
949 exclude_patterns = [
950- 'doc-cheat-sheet*',
951 ]
952
953 # Add custom CSS files (located in .sphinx/_static/)

Subscribers

People subscribed via source and target branches