Skip to content
Draft
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
18 changes: 18 additions & 0 deletions docs/_modules/redirects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import glob
import re

def source_redirects_glob_in_custom_format(file_paths_glob):
"""
Sources redirects from a filepath glob (such as "_redirects/*.txt"). This enables splitting the redirects into multiple files. Also, it uses custom format for redirects which is slightly different from the rediraffe format. It doesn't require quote marks and it supports comments by starting the line with a '# '.
"""
comment_syntax = r"# .*"
redirect_syntax = r"\"?([^\"\s]*)\"?\s*\"?([^\"\s]*)\"?"
redirects = {}
for file_path in glob.glob(file_paths_glob):
with open(file_path, "r") as file:
for line in file:
if not re.match(comment_syntax, line):
from_file, to_file = re.match(redirect_syntax, line).groups()
if from_file and to_file:
redirects[from_file] = to_file
return redirects
15 changes: 0 additions & 15 deletions docs/_modules/utilities.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import os
import sys
import glob
import re
import datetime

def current_year():
Expand All @@ -16,15 +13,3 @@ def optional_exclude_pattern(environment_variable, exclude_pattern):
else:
return []

def source_redirects(file_paths_glob):
comment_syntax = r"# .*"
redirect_syntax = r"\"?([^\"\s]*)\"?\s*\"?([^\"\s]*)\"?"
redirects = {}
for file_path in glob.glob(file_paths_glob):
with open(file_path, "r") as file:
for line in file:
if not re.match(comment_syntax, line):
from_file, to_file = re.match(redirect_syntax, line).groups()
if from_file and to_file:
redirects[from_file] = to_file
return redirects
File renamed without changes
17 changes: 9 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
import sys
sys.path.append(os.path.abspath("./_ext"))
sys.path.append(os.path.abspath("./_extensions"))
sys.path.insert(0, os.path.abspath('.'))
from _modules import utilities
from _modules import mock_imports
from _modules import redirects
from _modules import pr_preview
from _modules import utilities

build_mode = os.environ.get("BUILD_MODE")
git_branch = os.environ.get("BRANCH")
Expand Down Expand Up @@ -51,7 +52,7 @@
exclude_patterns += utilities.optional_exclude_pattern("LOCAL_ENABLE_TECH_ALERTS_CHANGELOG", "tech-alerts-changelog")

html_title = "DEA Knowledge Hub"
html_logo = "_files/logos/ga-dea-combined-logo.svg"
html_logo = "_static/logos/ga-dea-combined-logo.svg"
html_favicon = "_static/favicons/dea-favicon.ico"
html_theme = 'pydata_sphinx_theme'
language = "en"
Expand All @@ -61,19 +62,18 @@
else: html_baseurl = ""

html_permalinks = False
html_last_updated_fmt = '%-d %B %Y' # E.g. 1 January 2020

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.mathjax",
"myst_parser",
"nbsphinx",
"sphinx_design",
"sphinxext.rediraffe",
"sphinxcontrib.datatemplates",
"sphinxext.rediraffe",
"sphinx_external_toc",
"sphinx_sitemap",
"notfound.extension",
Expand All @@ -86,6 +86,7 @@
"attrs_block",
"dollarmath",
]

myst_heading_anchors = 6
myst_all_links_external = True

Expand All @@ -96,12 +97,12 @@

if (
is_production or is_pr_preview or enable_redirects
): rediraffe_redirects = utilities.source_redirects("_redirects/*.txt")
): rediraffe_redirects = redirects.source_redirects_glob_in_custom_format("_redirects/*.txt")

sitemap_url_scheme = "{link}"

ogp_site_url = "https://knowledge.dea.ga.gov.au/"
ogp_image = "/_files/logos/dea-logo-inline.png"
ogp_image = "/_static/logos/dea-logo-inline.png"

sys.path.insert(0, os.path.abspath("./notebooks/Tools"))
autosummary_generate = ["./notebooks/Tools/index.rst"]
Expand Down