Skip to content

Commit 9e73466

Browse files
make sphinx == strict_sphinx and bump to v7.3 (#35914)
* make sphinx == strict_sphinx and bump to v7.3 * strict sphinx only on dataplane * remove issue creator for sphinx, now mandatory in CI * test that we can still disable if needed * cleaning up docs and weekly template * try disable with artifacts * remove test skip
1 parent 0ed8e45 commit 9e73466

File tree

6 files changed

+30
-97
lines changed

6 files changed

+30
-97
lines changed

doc/eng_sys_checks.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ Starting with [this pr](https://github.com/Azure/azure-sdk-for-python/pull/28345
119119

120120
We default to **enabling** most of our checks like `pylint`, `mypy`, etc. Due to that, most `pyproject.toml` settings will likely be **disabling** checks.
121121

122-
There is also an additional setting to turn on strict sphinx validation, for docstring validation.
123-
124122
Here's an example:
125123

126124
```toml
@@ -133,7 +131,7 @@ verifytypes = false
133131
pyright = false
134132
pylint = false
135133
black = false
136-
strict_sphinx = false
134+
sphinx = false
137135
```
138136

139137
If a package does not yet have a `pyproject.toml`, creating one with just the section `[tool.azure-sdk-build]` will do no harm to the release of the package in question.
@@ -216,14 +214,11 @@ Note that the `pylint` environment is configured to run against the **earliest s
216214

217215
### Sphinx and docstring checker
218216

219-
[`Sphinx`](https://www.sphinx-doc.org/en/master/) is the preferred documentation builder for Python libraries. The documentation is always built and attached to each PR builds. Sphinx can be configured to
217+
[`Sphinx`](https://www.sphinx-doc.org/en/master/) is the preferred documentation builder for Python libraries. The documentation is always built and attached to each PR builds. Sphinx is configured to
220218
fail if docstring are invalid, helping to ensure the resulting documentation will be of high quality. Following are the steps to run `sphinx` locally for a specific package with strict docstring checking:
221219

222220
1. Go to root of the package.
223-
2. Make sure the `pyproject.toml` file contains `strict_sphinx = true`
224-
3. Execute following command: `tox run -e sphinx -c ../../../eng/tox/tox.ini --root .`
225-
226-
Note: While as of now the default value is `False`, it will become `True` by mid 2024.
221+
2. Execute following command: `tox run -e sphinx -c ../../../eng/tox/tox.ini --root .`
227222

228223
### Bandit
229224

eng/pipelines/templates/stages/python-analyze-weekly-standalone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,6 @@ extends:
112112
arguments: >-
113113
${{ parameters.BuildTargetingString }}
114114
--service="${{ parameters.ServiceDirectory }}"
115-
--toxenv="strict-sphinx"
115+
--toxenv="sphinx"
116116
env:
117117
GH_TOKEN: $(azuresdk-github-pat)

eng/pipelines/templates/stages/python-analyze-weekly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ stages:
109109
arguments: >-
110110
${{ parameters.BuildTargetingString }}
111111
--service="${{ parameters.ServiceDirectory }}"
112-
--toxenv="strict-sphinx"
112+
--toxenv="sphinx"
113113
env:
114114
GH_TOKEN: $(azuresdk-github-pat)

eng/tox/run_sphinx_build.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import logging
1515
import sys
1616
from prep_sphinx_env import should_build_docs
17+
from run_sphinx_apidoc import is_mgmt_package
1718
from pkg_resources import Requirement
1819
import ast
1920
import os
@@ -22,7 +23,7 @@
2223
import shutil
2324

2425
from ci_tools.parsing import ParsedSetup
25-
from ci_tools.functions import get_config_setting
26+
2627

2728
logging.getLogger().setLevel(logging.INFO)
2829

@@ -40,7 +41,7 @@ def move_output_and_compress(target_dir, package_dir, package_name):
4041
individual_zip_location = os.path.join(ci_doc_dir, package_name, package_name)
4142
shutil.make_archive(individual_zip_location, 'gztar', target_dir)
4243

43-
def sphinx_build(target_dir, output_dir, fail_on_warning=False, package_name=None):
44+
def sphinx_build(target_dir, output_dir, fail_on_warning):
4445
command_array = [
4546
"sphinx-build",
4647
"-b",
@@ -67,9 +68,6 @@ def sphinx_build(target_dir, output_dir, fail_on_warning=False, package_name=Non
6768
args.working_directory, e.returncode
6869
)
6970
)
70-
if args.strict and in_ci():
71-
from gh_tools.vnext_issue_creator import create_vnext_issue
72-
create_vnext_issue(package_name, "sphinx")
7371
exit(1)
7472

7573
if __name__ == "__main__":
@@ -108,12 +106,6 @@ def sphinx_build(target_dir, output_dir, fail_on_warning=False, package_name=Non
108106
default=False
109107
)
110108

111-
parser.add_argument(
112-
"--strict",
113-
dest="strict",
114-
default=False
115-
)
116-
117109
args = parser.parse_args()
118110

119111
output_dir = os.path.abspath(args.output_directory)
@@ -123,20 +115,16 @@ def sphinx_build(target_dir, output_dir, fail_on_warning=False, package_name=Non
123115
pkg_details = ParsedSetup.from_path(package_dir)
124116

125117
if should_build_docs(pkg_details.name):
126-
fail_on_warning = args.strict or get_config_setting(args.package_root, "strict_sphinx", default=False)
127-
118+
# Only data-plane libraries run strict sphinx at the moment
119+
fail_on_warning = not is_mgmt_package(pkg_details.name)
128120
sphinx_build(
129121
target_dir,
130122
output_dir,
131123
fail_on_warning=fail_on_warning,
132-
package_name=pkg_details.name
133124
)
134125

135126
if in_ci() or args.in_ci:
136127
move_output_and_compress(output_dir, package_dir, pkg_details.name)
137128

138-
if args.strict:
139-
from gh_tools.vnext_issue_creator import close_vnext_issue
140-
close_vnext_issue(pkg_details.name, "sphinx")
141129
else:
142130
logging.info("Skipping sphinx build for {}".format(pkg_details.name))

eng/tox/tox.ini

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ setenv =
324324
PROXY_URL=http://localhost:5007
325325
deps =
326326
{[base]deps}
327-
sphinx==6.2.1
327+
sphinx==7.3.7
328328
sphinx_rtd_theme==1.3.0
329329
myst_parser==2.0.0
330330
sphinxcontrib-jquery==4.1
@@ -342,35 +342,6 @@ commands =
342342
-r {tox_root}
343343

344344

345-
[testenv:strict-sphinx]
346-
description="Builds a package's documentation with strict sphinx"
347-
skipsdist = true
348-
skip_install = true
349-
passenv = *
350-
setenv =
351-
{[testenv]setenv}
352-
PROXY_URL=http://localhost:5023
353-
deps =
354-
{[base]deps}
355-
sphinx==7.3.7
356-
sphinx_rtd_theme==1.3.0
357-
myst_parser==2.0.0
358-
sphinxcontrib-jquery==4.1
359-
PyGitHub>=1.59.0
360-
commands =
361-
python {repository_root}/eng/tox/create_package_and_install.py \
362-
-d {envtmpdir}/dist \
363-
-p {tox_root} \
364-
-w {envtmpdir} \
365-
--package-type sdist
366-
python {repository_root}/eng/tox/prep_sphinx_env.py -d {envtmpdir}/dist -t {tox_root}
367-
python {repository_root}/eng/tox/run_sphinx_apidoc.py -w {envtmpdir}/dist -r {tox_root}
368-
python {repository_root}/eng/tox/run_sphinx_build.py \
369-
-w {envtmpdir}/dist/unzipped/docgen \
370-
-o {envtmpdir}/dist/site \
371-
-r {tox_root} \
372-
--strict true
373-
374345
[testenv:depends]
375346
description = Ensures all modules in a target package can be successfully imported
376347
setenv =

tools/azure-sdk-tools/gh_tools/vnext_issue_creator.py

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
logging.getLogger().setLevel(logging.INFO)
2020

21-
CHECK_TYPE = Literal["mypy", "pylint", "pyright", "sphinx"]
21+
CHECK_TYPE = Literal["mypy", "pylint", "pyright"]
2222

2323

2424
def get_version_running(check_type: CHECK_TYPE) -> str:
@@ -50,8 +50,6 @@ def get_build_link(check_type: CHECK_TYPE) -> str:
5050
next_id = "c0edaab3-85d6-5e4b-81a8-d1190a6ee92b"
5151
if check_type == "pylint":
5252
next_id = "e1fa7d9e-8471-5a74-cd7d-e1c9a992e07e"
53-
if check_type == "sphinx":
54-
next_id = "0d206e13-b346-5d3f-79e6-d5bfba9e089e"
5553

5654
return f"https://dev.azure.com/azure-sdk/internal/_build/results?buildId={build_id}&view=logs&j={job_id}&t={next_id}"
5755

@@ -104,43 +102,24 @@ def create_vnext_issue(package_name: str, check_type: CHECK_TYPE) -> None:
104102

105103
version = get_version_running(check_type)
106104
build_link = get_build_link(check_type)
107-
if check_type == "sphinx":
108-
merge_date = "2024-04-15" # This is a one-time event
109-
error_type = "docstring"
110-
guide_link = "[Sphinx and docstring checker](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/eng_sys_checks.md#sphinx-and-docstring-checker)"
111-
title = f"{package_name} needs {error_type} updates for {check_type}"
112-
template = (
113-
f"**ACTION NEEDED:** All {check_type} errors and warnings must be fixed by **{merge_date}**. "
114-
f"The build will begin to fail for this library if errors are not fixed."
115-
f"\n\nThis issue indicates that your library reference documentation is rendering with errors. To avoid customer issues, please ensure you take care of these errors and warnings ASAP."
116-
f"\n\n**Library name:** {package_name}"
117-
f"\n**{check_type.capitalize()} build:** [Link to build ({today.strftime('%Y-%m-%d')})]({build_link})"
118-
f"\n**How to fix:** Run the `strict-{check_type}` tox command at the library package-level and resolve "
119-
f"the {error_type} errors and warnings.\n"
120-
f"1) `../{package_name}>pip install \"tox<5\"`\n"
121-
f"2) `../{package_name}>tox run -e strict-{check_type} -c ../../../eng/tox/tox.ini --root .`\n\n"
122-
f"3) Once resolved, set `strict_sphinx = true` in the package's pyproject.toml file.\n\n"
123-
f"See {guide_link} for more information."
124-
)
125-
else:
126-
merge_date = get_date_for_version_bump(today)
127-
error_type = "linting" if check_type == "pylint" else "typing"
128-
guide_link = "[Pylint Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/pylint_checking.md)" \
129-
if check_type == "pylint" else "[Typing Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/static_type_checking.md#run-mypy)"
130-
131-
title = f"{package_name} needs {error_type} updates for {check_type} version {version}"
132-
template = (
133-
f"**ACTION NEEDED:** This version of {check_type} will be merged on **{merge_date}**. "
134-
f"The build will begin to fail for this library if errors are not fixed."
135-
f"\n\n**Library name:** {package_name}"
136-
f"\n**{check_type.capitalize()} version:** {version}"
137-
f"\n**{check_type.capitalize()} errors:** [Link to build ({today.strftime('%Y-%m-%d')})]({build_link})"
138-
f"\n**How to fix:** Run the `next-{check_type}` tox command at the library package-level and resolve "
139-
f"the {error_type} errors.\n"
140-
f"1) `../{package_name}>pip install \"tox<5\"`\n"
141-
f"2) `../{package_name}>tox run -e next-{check_type} -c ../../../eng/tox/tox.ini --root .`\n\n"
142-
f"See the {guide_link} for more information."
143-
)
105+
merge_date = get_date_for_version_bump(today)
106+
error_type = "linting" if check_type == "pylint" else "typing"
107+
guide_link = "[Pylint Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/pylint_checking.md)" \
108+
if check_type == "pylint" else "[Typing Guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/static_type_checking.md#run-mypy)"
109+
110+
title = f"{package_name} needs {error_type} updates for {check_type} version {version}"
111+
template = (
112+
f"**ACTION NEEDED:** This version of {check_type} will be merged on **{merge_date}**. "
113+
f"The build will begin to fail for this library if errors are not fixed."
114+
f"\n\n**Library name:** {package_name}"
115+
f"\n**{check_type.capitalize()} version:** {version}"
116+
f"\n**{check_type.capitalize()} errors:** [Link to build ({today.strftime('%Y-%m-%d')})]({build_link})"
117+
f"\n**How to fix:** Run the `next-{check_type}` tox command at the library package-level and resolve "
118+
f"the {error_type} errors.\n"
119+
f"1) `../{package_name}>pip install \"tox<5\"`\n"
120+
f"2) `../{package_name}>tox run -e next-{check_type} -c ../../../eng/tox/tox.ini --root .`\n\n"
121+
f"See the {guide_link} for more information."
122+
)
144123

145124
# create an issue for the library failing the vnext check
146125
if not vnext_issue:

0 commit comments

Comments
 (0)