Skip to content

Commit e2d12d7

Browse files
SecondSkollwaveform80dwildingerineconrkratky
authored
feat: Update stable branch with 1.3.0 release (#465)
* fix: CLA check to run on PRs only * refactor: Replace build_metrics.sh with something nicer (#373) * Replace build_metrics.sh with something nicer * docs: update changelog * docs: fix info about setting RTD key as GitHub deploy key (#423) * fix: spelling mistake in update script (#425) * fix spelling mistake in update script * add change to CHANGELOG.md * Add warning to set-up-automated-testing.rst (#427) * feat: exclude generated pages from sitemap by default, document wildcards (#429) * add info about wildcard excludes * add placeholder sitemap_excludes in conf.py * adjust wording of comment * enable typical sitemap_excludes by default * use consistent wording and formatting * Use long parameter for 'fail on warning' (#430) * docs: add troubleshooting how-to (#432) Add tag desync as the first issue. * Fix stale references to `custom_conf.py` (#433) * fix(ci): make check-removed-urls work with private forks (#437) * fix(ci): make check-removed-urls work with private forks Fixes #436 * docs: update changelog * chore: add `CODEOWNERS` (#439) * chore: add `CODEOWNERS` Enumerate individual reviewers for now. Later, we can add a Sphinx development team, once we've established one. * docs: add #438 to changelog * chore: missing hyphen Co-authored-by: Michael Park <[email protected]> * chore: revert changelog entry Co-authored-by: Michael Park <[email protected]> --------- Co-authored-by: Michael Park <[email protected]> * Update Open Graph image URL in conf.py (#441) The preview image being used was an old one, and the design team has suggested the use of this one instead. * Update workflow action versions (#445) * update workflow action versions * update changelog * Update CHANGELOG.md Co-authored-by: Dave Wilding <[email protected]> --------- Co-authored-by: Dave Wilding <[email protected]> * Fix whitespace and executable flag of scripts (#448) * make scripts executable * remove whitespace from vale script * update CHANGELOG.md * docs: add how-to guide for Mermaid diagramming tool (#442) Signed-off-by: annecyh <[email protected]> * Move from canonical-sphinx-exensions to individual packages (#449) * Move from canonical-sphinx-exensions to individual packages * Update CHANGELOG.md * build(deps): bump sphinx-terminal to v0.1.1 (#454) * docs: add how-to guide for sphinx autodoc extension (#450) * docs: update how to index.rst add autodocs * docs: create autodocs.md * fix: conf file formatting in autodocs.md * fix: fix conf.py formatting in autodocs.md * fix: pr comment updates * fix: requested pr changes Signed-off-by: Ashley Cliff <[email protected]> * fix: autodoc table formatting Signed-off-by: Ashley Cliff <[email protected]> * docs: update changelog for autodoc Signed-off-by: Ashley Cliff <[email protected]> * fix: autodoc spell fix Signed-off-by: Ashley Cliff <[email protected]> * fix: autodoc formatting Signed-off-by: Ashley Cliff <[email protected]> --------- Signed-off-by: Ashley Cliff <[email protected]> * build: move Vale dependencies to requirements.txt (#456) * move Vale dependencies to requirements.txt * add PR link to CHANGELOG.md * Add OpenAPI how-to guide (#446) * Add OpenAPI how-to guide * Include RTD steps in OpenAPI how-to guide * docs: add guidelines for using custom base templates (#455) * docs: add guidelines for using custom base templates Signed-off-by: annecyh <[email protected]> * docs: add a how-to guide for data tables (#451) * add first draft of data tables guide * add data tables guide to index * add details about Sphinx DataTables * adjust wording * update landing page per suggestion * adjust wording * mention new doc in CHANGELOG * remove full stop * put links in alphabetical order * use reST formatting * explain purpose of links and remove duplicated links * improve wording per review * docs: consolidate custom template information (#459) Signed-off-by: annecyh <[email protected]> * Details about sphinx-terminal (#447) * Details about sphinx-terminal * Describe the terminal copy button Co-authored-by: JJ Coldiron <[email protected]> * fix(build): remove em dash from fallback target (#461) #388 introduced an emdash in the makefile that was almost certainly not intended; this causes the fallthrough case to infinitely recurse. --------- Signed-off-by: Wesley Hershberger <[email protected]> Co-authored-by: Michael DuBelko <[email protected]> * feat!: incorporate redesigned terminal (#460) * fix(docs): update style guide redirects (#453) * docs: add step to remove CODEOWNERS in the tutorial (#458) Reorganise the first two sections so copying and pruning files are discrete actions. * Ensure update_sp.py is executable from any directory not just docs/ (#424) * ensure this file is executable from any directory not just docs/ * Add a new line * update requirements.txt path * update NEWFILES.txt path * chore: refactor makefile (#426) Co-authored-by: Michael Park <[email protected]> * chore: Remove `ALLFILES` from makefile (#434) * Remove `ALLFILES` from Makefile * Update changelog --------- Co-authored-by: Michael Park <[email protected]> * feat: better canonical URL support (#462) * fix: config for canonical URL * docs: update html_baseurl context in conf file * Update CHANGELOG.md * Update CHANGELOG.md * chore: reword changelog entry * chore: bump version * fix: CHANGELOG * fix: spelling issues --------- Signed-off-by: annecyh <[email protected]> Signed-off-by: Ashley Cliff <[email protected]> Signed-off-by: Wesley Hershberger <[email protected]> Co-authored-by: Dave Jones <[email protected]> Co-authored-by: Dave Wilding <[email protected]> Co-authored-by: Erin Conley <[email protected]> Co-authored-by: Robert Krátký <[email protected]> Co-authored-by: Michael DuBelko <[email protected]> Co-authored-by: tarek-y-ismail <[email protected]> Co-authored-by: Alex Lowe <[email protected]> Co-authored-by: Dimple Kuriakose <[email protected]> Co-authored-by: AnneCYH <[email protected]> Co-authored-by: Artem Konev <[email protected]> Co-authored-by: JJ Coldiron <[email protected]> Co-authored-by: Ashley Cliff <[email protected]> Co-authored-by: Marek Suchánek <[email protected]> Co-authored-by: Wesley Hershberger <[email protected]> Co-authored-by: Michael DuBelko <[email protected]> Co-authored-by: Charles Uneze <[email protected]>
1 parent 2ad0cc1 commit e2d12d7

37 files changed

+1592
-182
lines changed

.github/CODEOWNERS

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Codeowners for this repository.
2+
# Guidance and syntax is covered in
3+
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
4+
#
5+
# Important: The last match takes precedence.
6+
7+
# Development reviewers
8+
# Adjust this once we establish a Sphinx development team.
9+
* @akcano @dwilding @medubelko @minaelee @rkratky @SecondSkoll @tang-mm
10+
11+
# Changes to CODEOWNERS must be reviewed by admins
12+
/.github/CODEOWNERS @SecondSkoll
13+
14+
# Doc reviewers
15+
# /docs/

.github/workflows/check-removed-urls.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout PR branch
12-
uses: actions/checkout@v4
12+
uses: actions/checkout@v5
1313
with:
14-
repository: ${{ github.event.pull_request.head.repo.full_name }}
15-
ref: ${{ github.event.pull_request.head.ref }}
14+
# This implicitly gets the PR branch. Making it explicit causes problems
15+
# with private forks, but it is equivalent to the following:
16+
# repository: ${{ github.event.pull_request.head.repo.full_name }}
17+
# ref: ${{ github.event.pull_request.head.ref }}
1618
fetch-depth: 0
1719
path: compare
1820
- name: Checkout base branch
19-
uses: actions/checkout@v4
21+
uses: actions/checkout@v5
2022
with:
2123
ref: ${{ github.event.pull_request.base.ref }}
2224
repository: ${{ github.event.pull_request.base.repo.full_name }}
2325
fetch-depth: 0
2426
path: base
25-
- uses: actions/setup-python@v5
27+
- uses: actions/setup-python@v6
2628
- name: Build docs
2729
run: |
2830
for dir in compare base; do
@@ -51,4 +53,4 @@ jobs:
5153
echo "$removed"
5254
echo "Please ensure removed pages are redirected"
5355
exit 1
54-
fi
56+
fi

.github/workflows/cla-check.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# This workflow checks if the contributor has signed the Canonical Contributor Licence Agreement (CLA)
22
name: Canonical Contributor Licence Agreement check
3-
on: [pull_request]
3+
4+
on:
5+
pull_request:
6+
branches: [main]
47

58
jobs:
69
cla-check:

.github/workflows/markdown-style-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
markdown-lint:
1717
runs-on: ubuntu-22.04
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2020
with:
2121
fetch-depth: 0
2222
- name: Create venv

.github/workflows/sphinx-python-dependency-build-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- name: Checkout code
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@v5
3131

3232
- name: Install dependencies
3333
run: |
3434
set -ex
3535
sudo apt-get --fix-missing update
36-
sudo apt -y install \
36+
sudo apt-get -y install \
3737
cargo \
3838
libpython3-dev \
3939
libxml2-dev \

.github/workflows/test-starter-pack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Check out repo
17-
uses: actions/checkout@v4
17+
uses: actions/checkout@v5
1818
with:
1919
fetch-depth: 0
2020
- name: Build docs

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# sphinx-docs-starter-pack changelog
22

3+
## 1.3.0
4+
5+
* !!!BREAKING: Updated deps to use atomic extensions, not `canonical-sphinx[full]`. Updated `sphinx-terminal` uses backwards incompatible syntax
6+
* Changed `html_baseurl` for better canonical URL support
7+
* Changes metrics script to a less brittle Python script
8+
* Introduce guidelines for adding diagrams-as-code
9+
* Introduce guidelines for rendering CSV data as tables
10+
* Introduce guidelines for pulling in docstrings using Sphinx `autodoc` extension
11+
* Introduce guidelines for using custom base templates
12+
* Dropped unused makefile variable `ALLFILES`
13+
* Fix syntax error in Makefile that caused the fallback target to loop
14+
infinitely.
15+
* Add a step to the tutorial about removing `CODEOWNERS`.
16+
17+
### Added
18+
19+
* `docs/.sphinx/metrics/build_metrics.py` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)
20+
21+
## Changed
22+
23+
* `docs/Makefile` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373), [#456](https://github.com/canonical/sphinx-docs-starter-pack/pull/456)
24+
* `docs/requirements.txt` [#449](https://github.com/canonical/sphinx-docs-starter-pack/pull/449), [#456](https://github.com/canonical/sphinx-docs-starter-pack/pull/456), [#460](https://github.com/canonical/sphinx-docs-starter-pack/pull/460)
25+
* `docs/conf.py` [#429](https://github.com/canonical/sphinx-docs-starter-pack/pull/429), [#449](https://github.com/canonical/sphinx-docs-starter-pack/pull/449), [#442](https://github.com/canonical/sphinx-docs-starter-pack/pull/442), [#460](https://github.com/canonical/sphinx-docs-starter-pack/pull/460) [#462](https://github.com/canonical/sphinx-docs-starter-pack/pull/462)
26+
* `docs/.sphinx/get_vale_conf.py` [#448](https://github.com/canonical/sphinx-docs-starter-pack/pull/448)
27+
* `docs/.sphinx/update_sp.py` [#425](https://github.com/canonical/sphinx-docs-starter-pack/pull/425)
28+
* `docs/.sphinx/metrics/build_metrics.py` [#448](https://github.com/canonical/sphinx-docs-starter-pack/pull/448)
29+
* `.github/workflows/check-removed-urls.yml` [#437](https://github.com/canonical/sphinx-docs-starter-pack/pull/437), [#445](https://github.com/canonical/sphinx-docs-starter-pack/pull/445)
30+
* `.github/workflows/markdown-style-checks.yml` [#445](https://github.com/canonical/sphinx-docs-starter-pack/pull/445)
31+
* `.github/workflows/sphinx-python-dependency-build-checks.yml` [#445](https://github.com/canonical/sphinx-docs-starter-pack/pull/445)
32+
* `.github/workflows/test-starter-pack.yml` [#445](https://github.com/canonical/sphinx-docs-starter-pack/pull/445)
33+
* `docs/Makefile` [#461](https://github.com/canonical/sphinx-docs-starter-pack/pull/461)
34+
35+
### Removed
36+
37+
* `docs/.sphinx/metrics/build_metrics.sh` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)
38+
339
## 1.2.0
440

541
* Replaces spelling check with Vale.

docs/.custom_wordlist.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ texlive
3636
TOC
3737
toctree
3838
txt
39-
uncommenting
39+
uncomment(ing)?
4040
utils
4141
VMs
4242
WCAG
@@ -63,3 +63,9 @@ Spread
6363
landscape
6464
lastmod
6565
yaml
66+
sequenceDiagram
67+
Numpy
68+
openapi
69+
docstrings?
70+
Makefile
71+
retrigger(ing)?

docs/.sphinx/get_vale_conf.py

100644100755
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
def clone_repo_and_copy_paths(file_source_dest, overwrite=False):
3232
"""
3333
Clone the repository to a temporary directory and copy required files
34-
34+
3535
Args:
3636
file_source_dest: dictionary of file paths to copy from the repository,
3737
and their destination paths
3838
overwrite: boolean flag to overwrite existing files in the destination
39-
39+
4040
Returns:
4141
bool: True if all files were copied successfully, False otherwise
4242
"""
@@ -52,8 +52,8 @@ def clone_repo_and_copy_paths(file_source_dest, overwrite=False):
5252

5353
try:
5454
result = subprocess.run(
55-
clone_cmd,
56-
capture_output=True,
55+
clone_cmd,
56+
capture_output=True,
5757
text=True,
5858
check=True
5959
)
@@ -73,7 +73,7 @@ def clone_repo_and_copy_paths(file_source_dest, overwrite=False):
7373
continue
7474

7575
if not copy_files_to_path(source_path, dest, overwrite):
76-
is_copy_success = False
76+
is_copy_success = False
7777
logging.error("Failed to copy %s to %s", source_path, dest)
7878

7979
# Clean up temporary directory
@@ -85,12 +85,12 @@ def clone_repo_and_copy_paths(file_source_dest, overwrite=False):
8585
def copy_files_to_path(source_path, dest_path, overwrite=False):
8686
"""
8787
Copy a file or directory from source to destination
88-
88+
8989
Args:
9090
source_path: Path to the source file or directory
9191
dest_path: Path to the destination
9292
overwrite: Boolean flag to overwrite existing files in the destination
93-
93+
9494
Returns:
9595
bool: True if copy was successful, False otherwise
9696
"""
@@ -138,7 +138,7 @@ def main():
138138
# Parse command line arguments, default to overwrite_enabled = True
139139
overwrite_enabled = not parse_arguments().no_overwrite
140140

141-
# Download into /tmp through git clone
141+
# Download into /tmp through git clone
142142
if not clone_repo_and_copy_paths(vale_files_dict, overwrite=overwrite_enabled):
143143
logging.error("Failed to download files from repository")
144144
return 1
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/python3
2+
3+
import sys
4+
import argparse
5+
from pathlib import Path
6+
from html.parser import HTMLParser
7+
from urllib.parse import urlsplit
8+
9+
10+
class MetricsParser(HTMLParser):
11+
def __init__(self):
12+
super().__init__()
13+
self.int_link_count = 0
14+
self.ext_link_count = 0
15+
self.fragment_count = 0
16+
self.image_count = 0
17+
self.in_object = 0
18+
19+
@property
20+
def link_count(self):
21+
return self.fragment_count + self.int_link_count + self.ext_link_count
22+
23+
def read(self, file):
24+
"""
25+
Read *file* (a file-like object with a ``read`` method returning
26+
strings) a chunk at a time, feeding each chunk to the parser.
27+
"""
28+
# Ensure the parser state is reset before each file (just in case
29+
# there's an erroneous dangling <object>)
30+
self.reset()
31+
self.in_object = 0
32+
buf = ''
33+
while True:
34+
# Parse 1MB chunks at a time
35+
buf = file.read(1024**2)
36+
if not buf:
37+
break
38+
self.feed(buf)
39+
40+
def handle_starttag(self, tag, attrs):
41+
"""
42+
Count <a>, <img>, and <object> tags to determine the number of internal
43+
and external links, and the number of images.
44+
"""
45+
attrs = dict(attrs)
46+
if tag == 'a' and 'href' in attrs:
47+
# If there's no href, it's an anchor; if there's no hostname
48+
# (netloc) or path, it's just a fragment link within the page
49+
url = urlsplit(attrs['href'])
50+
if url.netloc:
51+
self.ext_link_count += 1
52+
elif url.path:
53+
self.int_link_count += 1
54+
else:
55+
self.fragment_count += 1
56+
elif tag == 'object':
57+
# <object> tags are a bit complex as they nest to offer fallbacks
58+
# and may contain an <img> fallback. We only want to count the
59+
# outer-most <object> in this case
60+
if self.in_object == 0:
61+
self.image_count += 1
62+
self.in_object += 1
63+
elif tag == 'img' and self.in_object == 0:
64+
self.image_count += 1
65+
66+
def handle_endtag(self, tag):
67+
if tag == 'object':
68+
# Never let in_object be negative
69+
self.in_object = max(0, self.in_object - 1)
70+
71+
72+
def main(args=None):
73+
parser = argparse.ArgumentParser()
74+
parser.add_argument(
75+
'build_dir', metavar='build-dir', nargs='?', default='.',
76+
help="The directory to scan for HTML files")
77+
config = parser.parse_args(args)
78+
79+
parser = MetricsParser()
80+
for path in Path(config.build_dir).rglob('*.html'):
81+
with path.open('r', encoding='utf-8', errors='replace') as f:
82+
parser.read(f)
83+
84+
print('Summarising metrics for build files (.html)...')
85+
print(f'\tlinks: {parser.link_count} ('
86+
f'{parser.fragment_count} #frag…, '
87+
f'{parser.int_link_count} /int…, '
88+
f'{parser.ext_link_count} https://ext…'
89+
')')
90+
print(f'\timages: {parser.image_count}')
91+
92+
93+
if __name__ == '__main__':
94+
sys.exit(main())

0 commit comments

Comments
 (0)