Skip to content

Commit

Permalink
doc: configure sphinx conf.py for content reuse
Browse files Browse the repository at this point in the history
Read reuse/substitutions.yaml if it exists into myst_substitutions to
reuse content with simple markdown.

Additionally, delete reuse/links.txt since we are not using
reStructuredText.

This commit also updates a few misc settings in conf.py.
  • Loading branch information
rebornplusplus authored and cjdcordeiro committed Dec 16, 2024
1 parent f608f7a commit 5b95713
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
25 changes: 18 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import datetime
import ast
import datetime
import os
import yaml

# Configuration for the Sphinx documentation builder.
# All configuration specific to your project should be done in this file.
Expand Down Expand Up @@ -59,7 +61,7 @@
# -H 'Accept: application/vnd.github.v3.raw' \
# https://api.github.com/repos/canonical/<REPO> | jq '.created_at'

copyright = "%s CC-BY-SA, %s" % (datetime.date.today().year, author)
copyright = "%s AGPL-3.0, %s" % (datetime.date.today().year, author)


# Documentation website URL
Expand Down Expand Up @@ -142,7 +144,7 @@
"github_folder": "/docs/",
# TODO: To enable or disable the Previous / Next buttons at the bottom of pages
# Valid options: none, prev, next, both
# "sequential_nav": "both",
"sequential_nav": "both",
}

# Project slug; see https://meta.discourse.org/t/what-is-category-slug/87897
Expand Down Expand Up @@ -183,7 +185,7 @@
#
# TODO: Remove or adjust the ACME entry after you update the contributing guide

linkcheck_ignore = ["http://127.0.0.1:8000", "https://github.com/canonical/ACME/*"]
linkcheck_ignore = ["http://127.0.0.1:8000"]


# A regex list of URLs where anchors are ignored by 'make linkcheck'
Expand Down Expand Up @@ -249,9 +251,18 @@

# Specifies a reST snippet to be appended to each .rst file

rst_epilog = """
.. include:: /reuse/links.txt
"""
if os.path.exists('./reuse/links.txt'):
rst_epilog = """
.. include:: /reuse/links.txt
"""

# To reuse sentences or paragraphs that have little markup and special
# formatting, use substitutions.
# https://canonical-documentation-with-sphinx-and-readthedocscom.readthedocs-hosted.com/style-guide-myst/#substitution

if os.path.exists('./reuse/substitutions.yaml'):
with open('./reuse/substitutions.yaml', 'r') as fd:
myst_substitutions = yaml.safe_load(fd.read())

# Feedback button at the top; enabled by default
#
Expand Down
1 change: 0 additions & 1 deletion docs/reuse/links.txt

This file was deleted.

0 comments on commit 5b95713

Please sign in to comment.