|
6 | 6 |
|
7 | 7 | # -- Path setup --------------------------------------------------------------
|
8 | 8 |
|
9 |
| -# If extensions (or modules to document with autodoc) are in another directory, |
10 |
| -# add these directories to sys.path here. If the directory is relative to the |
11 |
| -# documentation root, use os.path.abspath to make it absolute, like shown here. |
12 |
| - |
13 | 9 | import csv
|
14 | 10 | import json
|
15 | 11 | import os
|
|
24 | 20 |
|
25 | 21 | # -- Project information -----------------------------------------------------
|
26 | 22 |
|
27 |
| -project = 'Open Contracting Data Standard' |
28 |
| -copyright = 'Open Contracting Partnership' |
29 |
| -author = 'Open Contracting Partnership' |
| 23 | +project = "Open Contracting Data Standard" |
| 24 | +copyright = "Open Contracting Partnership" |
| 25 | +author = "Open Contracting Partnership" |
30 | 26 |
|
31 |
| -version = '1.1' |
32 |
| -release = '1.1.5' |
| 27 | +version = "1.1" |
| 28 | +release = "1.1.5" |
33 | 29 |
|
34 | 30 |
|
35 | 31 | # -- General configuration ---------------------------------------------------
|
|
38 | 34 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
39 | 35 | # ones.
|
40 | 36 | extensions = [
|
41 |
| - 'myst_parser', |
42 |
| - 'sphinx.ext.ifconfig', |
43 |
| - 'sphinxcontrib.jsonschema', |
44 |
| - 'sphinxcontrib.opencontracting', |
45 |
| - 'sphinxcontrib.opendataservices', |
46 |
| - 'sphinx_design', |
| 37 | + "myst_parser", |
| 38 | + "sphinx.ext.ifconfig", |
| 39 | + "sphinxcontrib.jsonschema", |
| 40 | + "sphinxcontrib.opencontracting", |
| 41 | + "sphinxcontrib.opendataservices", |
| 42 | + "sphinx_design", |
47 | 43 | ]
|
48 | 44 |
|
49 | 45 | # Add any paths that contain templates here, relative to this directory.
|
50 |
| -templates_path = ['_templates'] |
| 46 | +templates_path = ["_templates"] |
51 | 47 |
|
52 | 48 | # List of patterns, relative to source directory, that match files and
|
53 | 49 | # directories to ignore when looking for source files.
|
54 | 50 | # This pattern also affects html_static_path and html_extra_path.
|
55 |
| -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**/docson/[!p]**', '**/docson/package*.json'] |
| 51 | +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**/docson/[!p]**", "**/docson/package*.json"] |
56 | 52 |
|
57 | 53 |
|
58 | 54 | # -- Options for HTML output -------------------------------------------------
|
59 | 55 |
|
60 | 56 | # The theme to use for HTML and HTML Help pages. See the documentation for
|
61 | 57 | # a list of builtin themes.
|
62 | 58 | #
|
63 |
| -html_theme = 'standard_theme' # 'pydata_sphinx_theme' |
| 59 | +html_theme = "standard_theme" # 'pydata_sphinx_theme' |
64 | 60 | html_theme_path = [standard_theme.get_html_theme_path()]
|
65 |
| -html_favicon = '_static/favicon-16x16.ico' |
| 61 | +html_favicon = "_static/favicon-16x16.ico" |
66 | 62 |
|
67 | 63 | # Add any paths that contain custom static files (such as style sheets) here,
|
68 | 64 | # relative to this directory. They are copied after the builtin static files,
|
69 | 65 | # so a file named "default.css" will overwrite the builtin "default.css".
|
70 |
| -html_static_path = ['_static'] |
| 66 | +html_static_path = ["_static"] |
71 | 67 |
|
72 | 68 |
|
73 | 69 | # -- Local configuration -----------------------------------------------------
|
74 | 70 |
|
75 |
| -_ = get_translation('theme') |
| 71 | +_ = get_translation("theme") |
76 | 72 |
|
77 |
| -profile_identifier = '' |
78 |
| -repository_url = 'https://github.com/open-contracting/standard' |
| 73 | +profile_identifier = "" |
| 74 | +repository_url = "https://github.com/open-contracting/standard" |
79 | 75 |
|
80 | 76 | # Internationalization.
|
81 | 77 | gettext_compact = False
|
82 | 78 | # `DOMAIN_PREFIX` from `config.mk`.
|
83 |
| -gettext_domain_prefix = f'{profile_identifier}-' if profile_identifier else '' |
84 |
| -locale_dirs = ['locale/', os.path.join(standard_theme.get_html_theme_path(), 'locale')] |
| 79 | +gettext_domain_prefix = f"{profile_identifier}-" if profile_identifier else "" |
| 80 | +locale_dirs = ["locale/", os.path.join(standard_theme.get_html_theme_path(), "locale")] |
85 | 81 | # We use single quotes for codes, which docutils will change to double quotes.
|
86 | 82 | # https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/docutils/utils/smartquotes.py
|
87 | 83 | smartquotes = False
|
88 | 84 |
|
89 | 85 | # MyST configuration.
|
90 |
| -myst_enable_extensions = ['linkify'] |
| 86 | +myst_enable_extensions = ["linkify"] |
91 | 87 | myst_heading_anchors = 6
|
92 | 88 | myst_heading_slug_func = make_id
|
93 | 89 | # https://github.com/executablebooks/MyST-Parser/issues/357
|
94 |
| -suppress_warnings = ['myst.anchor'] |
| 90 | +suppress_warnings = ["myst.anchor"] |
95 | 91 |
|
96 | 92 | # Theme customization.
|
97 | 93 | navigation_with_keys = False # restore the Sphinx default
|
98 | 94 | html_context = {
|
99 |
| - 'analytics_id': 'HTWZHRIZ', |
| 95 | + "analytics_id": "HTWZHRIZ", |
100 | 96 | }
|
101 | 97 | html_theme_options = {
|
102 |
| - 'analytics_id': 'HTWZHRIZ', |
103 |
| - 'display_version': True, |
104 |
| - 'root_url': f'/profiles/{profile_identifier}' if profile_identifier else '', |
105 |
| - 'short_project': project.replace('Open Contracting Data Standard', 'OCDS'), |
106 |
| - 'copyright': copyright, |
107 |
| - 'license_name': 'Apache License 2.0', |
108 |
| - 'license_url': f'{repository_url}/blob/HEAD/LICENSE', |
109 |
| - 'repository_url': repository_url, |
| 98 | + "analytics_id": "HTWZHRIZ", |
| 99 | + "display_version": True, |
| 100 | + "root_url": f"/profiles/{profile_identifier}" if profile_identifier else "", |
| 101 | + "short_project": project.replace("Open Contracting Data Standard", "OCDS"), |
| 102 | + "copyright": copyright, |
| 103 | + "license_name": "Apache License 2.0", |
| 104 | + "license_url": f"{repository_url}/blob/HEAD/LICENSE", |
| 105 | + "repository_url": repository_url, |
110 | 106 | }
|
111 |
| -html_short_title = f'{html_theme_options["short_project"]} v{release}' |
| 107 | +html_short_title = f"{html_theme_options['short_project']} v{release}" |
112 | 108 |
|
113 | 109 | # List the extension identifiers and versions that should be part of this specification. The extensions must be in
|
114 | 110 | # the extension registry: https://github.com/open-contracting/extension_registry/blob/main/extension_versions.csv
|
115 |
| -default_extension_version = f'v{release}' |
| 111 | +default_extension_version = f"v{release}" |
116 | 112 | extension_versions = {
|
117 |
| - 'bids': default_extension_version, |
118 |
| - 'enquiries': default_extension_version, |
119 |
| - 'location': default_extension_version, |
120 |
| - 'lots': default_extension_version, |
121 |
| - 'milestone_documents': default_extension_version, |
122 |
| - 'participation_fee': default_extension_version, |
123 |
| - 'process_title': default_extension_version, |
| 113 | + "bids": default_extension_version, |
| 114 | + "enquiries": default_extension_version, |
| 115 | + "location": default_extension_version, |
| 116 | + "lots": default_extension_version, |
| 117 | + "milestone_documents": default_extension_version, |
| 118 | + "participation_fee": default_extension_version, |
| 119 | + "process_title": default_extension_version, |
124 | 120 | }
|
125 | 121 |
|
126 | 122 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder
|
127 | 123 | # Ignore Google Sheets.
|
128 |
| -linkcheck_anchors_ignore = [r'^gid='] |
| 124 | +linkcheck_anchors_ignore = [r"^gid="] |
129 | 125 | linkcheck_ignore = [
|
130 | 126 | # Avoid GitHub.com rate limiting.
|
131 |
| - r'^https://github.com/open-contracting/standard/(?:issues|pull)/\d+$', |
| 127 | + r"^https://github.com/open-contracting/standard/(?:issues|pull)/\d+$", |
132 | 128 | # Ignore irreproducible false positives.
|
133 |
| - r'^https://www.fcny.org/fcny/$', |
134 |
| - r'^http://www.eprocurementtoolkit.org/sites/default/files/2016-11/OCDS_Implemetation_Methodology_0.pdf#page=27$', |
| 129 | + r"^https://www.fcny.org/fcny/$", |
| 130 | + r"^http://www.eprocurementtoolkit.org/sites/default/files/2016-11/OCDS_Implemetation_Methodology_0.pdf#page=27$", |
135 | 131 | # Ignore unwanted links created by linkify.
|
136 |
| - r'^http://vnd\.', |
| 132 | + r"^http://vnd\.", |
137 | 133 | # Ignore expected redirects.
|
138 |
| - r'^https://docs.google.com/spreadsheets/d/[^/]+/pub?gid=\d+&single=true&output=csv$', |
| 134 | + r"^https://docs.google.com/spreadsheets/d/[^/]+/pub?gid=\d+&single=true&output=csv$", |
139 | 135 | ]
|
140 | 136 |
|
141 | 137 |
|
142 | 138 | def setup(app):
|
143 | 139 | # The root of the repository.
|
144 | 140 | basedir = Path(__file__).resolve().parents[1]
|
145 | 141 | # `LOCALE_DIR` from `config.mk`.
|
146 |
| - localedir = basedir / 'docs' / 'locale' |
| 142 | + localedir = basedir / "docs" / "locale" |
147 | 143 |
|
148 |
| - language = app.config.overrides.get('language', 'en') |
| 144 | + language = app.config.overrides.get("language", "en") |
149 | 145 |
|
150 |
| - headers = ['Title', 'Description', 'Extension'] |
| 146 | + headers = ["Title", "Description", "Extension"] |
151 | 147 | # The gettext domain for schema translations. Should match the domain in the `pybabel compile` command.
|
152 |
| - schema_domain = f'{gettext_domain_prefix}schema' |
| 148 | + schema_domain = f"{gettext_domain_prefix}schema" |
153 | 149 | # The gettext domain for codelist translations. Should match the domain in the `pybabel compile` command.
|
154 |
| - codelists_domain = f'{gettext_domain_prefix}codelists' |
155 |
| - |
156 |
| - standard_dir = basedir / 'schema' |
157 |
| - standard_build_dir = basedir / 'build' / language |
158 |
| - |
159 |
| - branch = os.getenv('GITHUB_REF_NAME', 'latest') |
160 |
| - |
161 |
| - translate([ |
162 |
| - # The glob patterns in `babel_ocds_schema.cfg` should match these filenames. |
163 |
| - (glob(str(standard_dir / '*-schema.json')), standard_build_dir, schema_domain), |
164 |
| - # The glob patterns in `babel_ocds_codelist.cfg` should match these. |
165 |
| - (glob(str(standard_dir / 'codelists' / '*.csv')), standard_build_dir / 'codelists', codelists_domain), |
166 |
| - ], localedir, language, headers, version=branch) |
167 |
| - |
168 |
| - with (standard_build_dir / 'release-schema.json').open() as f: |
| 150 | + codelists_domain = f"{gettext_domain_prefix}codelists" |
| 151 | + |
| 152 | + standard_dir = basedir / "schema" |
| 153 | + standard_build_dir = basedir / "build" / language |
| 154 | + |
| 155 | + branch = os.getenv("GITHUB_REF_NAME", "latest") |
| 156 | + |
| 157 | + translate( |
| 158 | + [ |
| 159 | + # The glob patterns in `babel_ocds_schema.cfg` should match these filenames. |
| 160 | + (glob(str(standard_dir / "*-schema.json")), standard_build_dir, schema_domain), |
| 161 | + # The glob patterns in `babel_ocds_codelist.cfg` should match these. |
| 162 | + (glob(str(standard_dir / "codelists" / "*.csv")), standard_build_dir / "codelists", codelists_domain), |
| 163 | + ], |
| 164 | + localedir, |
| 165 | + language, |
| 166 | + headers, |
| 167 | + version=branch, |
| 168 | + ) |
| 169 | + |
| 170 | + with (standard_build_dir / "release-schema.json").open() as f: |
169 | 171 | fieldnames, rows = mapping_sheet(json.load(f), infer_required=True)
|
170 | 172 |
|
171 |
| - with (standard_build_dir / 'release-schema.csv').open('w') as f: |
| 173 | + with (standard_build_dir / "release-schema.csv").open("w") as f: |
172 | 174 | writer = csv.DictWriter(f, fieldnames)
|
173 | 175 | writer.writeheader()
|
174 | 176 | writer.writerows(rows)
|
0 commit comments