Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,15 @@ jobs:
- run: pip install pygithub click
- name: Check that the CODEOWNERS is valid
run: python .github/workflows/notify_codeowners.py .github/CODEOWNERS
tutorial-table-of-contents:
name: Check that all tutorials are included in documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- run: pip install pyyaml
- name: Check that all tutorials are included in table of contents
run: python .github/workflows/verify_tutorial_toc.py

46 changes: 46 additions & 0 deletions .github/workflows/verify_tutorial_toc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import yaml
from pathlib import Path


def get_yaml_links():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be cleaner to have that as a pytest test in tools/testing/check_source_code.py? Or in a separate file in this directory? Then we run everything with pytest in one single Github actions job.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, will refactor the test to be in standard testing location.

with open("docs/tutorials/_toc.yaml", "r") as stream:
toc = yaml.safe_load(stream)["toc"]

links = [x["path"].split("/")[-1] for x in toc if "path" in x]
links.remove("overview")

links_set = set(links)
assert len(links) == len(
links_set
), "There are duplicate links in the table of contents"

return links_set


def get_tutorial_notebooks():
tutorial_dir = Path("docs/tutorials")
notebooks = [x.stem for x in tutorial_dir.glob("*.ipynb")]
notebooks.remove("_template")

notebook_set = set(notebooks)

assert len(notebooks) == len(notebook_set), "There are duplicate notebook filenames"

return notebook_set


def verify_table_of_contents():

links = get_yaml_links()
tutorials = get_tutorial_notebooks()
difference = links ^ tutorials

assert (
len(difference) == 0
), "{0} tutorials were not found as ipython notebooks and table of contents links".format(
difference
)


if __name__ == "__main__":
verify_table_of_contents()
4 changes: 4 additions & 0 deletions docs/tutorials/_toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ toc:
path: /addons/tutorials/tqdm_progress_bar
- title: Seq2Seq for Translation
path: /addons/tutorials/networks_seq2seq_nmt
- title: Moving Average Optimizer Checkpoint
path: /addons/tutorials/average_optimizers_callback
- title: Time Stopping Callback
path: /addons/tutorials/time_stopping