-
Notifications
You must be signed in to change notification settings - Fork 10
docs: upgrade starter pack with gemini 3 pro - second attempt #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tmihoc
merged 2 commits into
canonical:v3
from
tmihoc:v3-upgrade-starter-pack-with-gemini-3-pro-2
Dec 11, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,4 @@ jobs: | |
| with: | ||
| working-directory: "." | ||
| fetch-depth: 0 | ||
| spelling-target: "help" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/usr/bin/python3 | ||
|
|
||
| import sys | ||
| import argparse | ||
| from pathlib import Path | ||
| from html.parser import HTMLParser | ||
| from urllib.parse import urlsplit | ||
|
|
||
|
|
||
| class MetricsParser(HTMLParser): | ||
| def __init__(self): | ||
| super().__init__() | ||
| self.int_link_count = 0 | ||
| self.ext_link_count = 0 | ||
| self.fragment_count = 0 | ||
| self.image_count = 0 | ||
| self.in_object = 0 | ||
|
|
||
| @property | ||
| def link_count(self): | ||
| return self.fragment_count + self.int_link_count + self.ext_link_count | ||
|
|
||
| def read(self, file): | ||
| """ | ||
| Read *file* (a file-like object with a ``read`` method returning | ||
| strings) a chunk at a time, feeding each chunk to the parser. | ||
| """ | ||
| # Ensure the parser state is reset before each file (just in case | ||
| # there's an erroneous dangling <object>) | ||
| self.reset() | ||
| self.in_object = 0 | ||
| buf = '' | ||
| while True: | ||
| # Parse 1MB chunks at a time | ||
| buf = file.read(1024**2) | ||
| if not buf: | ||
| break | ||
| self.feed(buf) | ||
|
|
||
| def handle_starttag(self, tag, attrs): | ||
| """ | ||
| Count <a>, <img>, and <object> tags to determine the number of internal | ||
| and external links, and the number of images. | ||
| """ | ||
| attrs = dict(attrs) | ||
| if tag == 'a' and 'href' in attrs: | ||
| # If there's no href, it's an anchor; if there's no hostname | ||
| # (netloc) or path, it's just a fragment link within the page | ||
| url = urlsplit(attrs['href']) | ||
| if url.netloc: | ||
| self.ext_link_count += 1 | ||
| elif url.path: | ||
| self.int_link_count += 1 | ||
| else: | ||
| self.fragment_count += 1 | ||
| elif tag == 'object': | ||
| # <object> tags are a bit complex as they nest to offer fallbacks | ||
| # and may contain an <img> fallback. We only want to count the | ||
| # outer-most <object> in this case | ||
| if self.in_object == 0: | ||
| self.image_count += 1 | ||
| self.in_object += 1 | ||
| elif tag == 'img' and self.in_object == 0: | ||
| self.image_count += 1 | ||
|
|
||
| def handle_endtag(self, tag): | ||
| if tag == 'object': | ||
| # Never let in_object be negative | ||
| self.in_object = max(0, self.in_object - 1) | ||
|
|
||
|
|
||
| def main(args=None): | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument( | ||
| 'build_dir', metavar='build-dir', nargs='?', default='.', | ||
| help="The directory to scan for HTML files") | ||
| config = parser.parse_args(args) | ||
|
|
||
| parser = MetricsParser() | ||
| for path in Path(config.build_dir).rglob('*.html'): | ||
| with path.open('r', encoding='utf-8', errors='replace') as f: | ||
| parser.read(f) | ||
|
|
||
| print('Summarising metrics for build files (.html)...') | ||
| print(f'\tlinks: {parser.link_count} (' | ||
| f'{parser.fragment_count} #frag…, ' | ||
| f'{parser.int_link_count} /int…, ' | ||
| f'{parser.ext_link_count} https://ext…' | ||
| ')') | ||
| print(f'\timages: {parser.image_count}') | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/bin/bash | ||
| # shellcheck disable=all | ||
|
|
||
| VENV=".sphinx/venv/bin/activate" | ||
|
|
||
| files=0 | ||
| words=0 | ||
| readabilityWords=0 | ||
| readabilitySentences=0 | ||
| readabilitySyllables=0 | ||
| readabilityAverage=0 | ||
| readable=true | ||
|
|
||
| # measure number of files (.rst and .md), excluding those in .sphinx dir | ||
| files=$(find . -type d -path './.sphinx' -prune -o -type f \( -name '*.md' -o -name '*.rst' \) -print | wc -l) | ||
|
|
||
| # calculate metrics only if source files are present | ||
| if [ "$files" -eq 0 ]; then | ||
| echo "There are no source files to calculate metrics" | ||
| else | ||
| # measure raw total number of words, excluding those in .sphinx dir | ||
| words=$(find . -type d -path './.sphinx' -prune -o \( -name '*.md' -o -name '*.rst' \) -exec cat {} + | wc -w) | ||
|
|
||
| # calculate readability for markdown source files | ||
| echo "Activating virtual environment to run vale..." | ||
| source "${VENV}" | ||
|
|
||
| for file in *.md *.rst; do | ||
| if [ -f "$file" ]; then | ||
| readabilityWords=$(vale ls-metrics "$file" | grep '"words"' | sed 's/[^0-9]*//g') | ||
| readabilitySentences=$(vale ls-metrics "$file" | grep '"sentences"' | sed 's/[^0-9]*//g') | ||
| readabilitySyllables=$(vale ls-metrics "$file" | grep '"syllables"' | sed 's/[^0-9]*//g') | ||
| fi | ||
| done | ||
|
|
||
| echo "Deactivating virtual environment..." | ||
| deactivate | ||
|
|
||
| # calculate mean number of words | ||
| if [ "$files" -ge 1 ]; then | ||
| meanval=$((readabilityWords / files)) | ||
| else | ||
| meanval=$readabilityWords | ||
| fi | ||
|
|
||
| readabilityAverage=$(echo "scale=2; 0.39 * ($readabilityWords / $readabilitySentences) + (11.8 * ($readabilitySyllables / $readabilityWords)) - 15.59" | bc) | ||
|
|
||
| # cast average to int for comparison | ||
| readabilityAverageInt=$(echo "$readabilityAverage / 1" | bc) | ||
|
|
||
| # value below 8 is considered readable | ||
| if [ "$readabilityAverageInt" -lt 8 ]; then | ||
| readable=true | ||
| else | ||
| readable=false | ||
| fi | ||
|
|
||
| # summarise latest metrics | ||
| echo "Summarising metrics for source files (.md, .rst)..." | ||
| echo -e "\ttotal files: $files" | ||
| echo -e "\ttotal words (raw): $words" | ||
| echo -e "\ttotal words (prose): $readabilityWords" | ||
| echo -e "\taverage word count: $meanval" | ||
| echo -e "\treadability: $readabilityAverage" | ||
| echo -e "\treadable: $readable" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 1.2.0 | ||
| 1.3.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to turn this back on in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. In fact we should turn on the full battery of tests that's in the Starter Pack.