Skip to content

Commit e1b2269

Browse files
author
Release Manager
committed
gh-38100: Remove nitpick_patch_config function <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Fixes #37996. We remove this function ```python def nitpick_patch_config(app): """ Patch the default config for nitpicky [...] ensure that nitpicky is not considered as a Sphinx environment variable but rather as a Sage environment variable. As a consequence, changing it doesn't force the recompilation of the entire documentation. """ app.config.values['nitpicky'] = (False, 'sage') app.config.values['nitpick_ignore'] = ([], 'sage') ``` from `src/sage_docbuild/conf.py`. The original purpose of the function seems to change `"env"` to `"sage"` for `nitpicky` config variable. But the recent Sphinx is setting `""` (empty string) instead of `"env"` by default. See https://github.com/sphinx-doc/sphinx/blob/48cbb43e28efe82b198137042811e0 ade3599ae7/sphinx/config.py#L250C1-L250C41 - Hence the function is already no-op. But this old and obsolete function is the cause of #37996. Hence we simply remove it. - To prepare for Sphinx 7.3.7, we also remove some code which seems to have become obsolete when `sage -clone` was removed long time ago. - Made some docstring up-to-date, to test incremental doc build. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #38100 Reported by: Kwankyu Lee Reviewer(s):
2 parents bbce0cd + 6489d4c commit e1b2269

3 files changed

Lines changed: 55 additions & 76 deletions

File tree

src/sage_docbuild/__main__.py

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,62 @@
1414
1515
Positional arguments::
1616
17-
DOCUMENT name of the document to build. It can be either one
18-
of the documents listed by -D or 'file=/path/to/FILE' to build documentation
19-
for this specific file.
20-
FORMAT or COMMAND document output format (or command)
17+
DOCUMENT name of the document to build. It can be either one of
18+
the documents listed by -D or 'file=/path/to/FILE' to
19+
build documentation for this specific file.
20+
FORMAT or COMMAND document output format (or command)
2121
2222
Standard options::
2323
24-
-h, --help show a help message and exit
25-
-H, --help-all show an extended help message and exit
26-
-D, --documents list all available DOCUMENTs
27-
-F, --formats list all output FORMATs
28-
-C DOC, --commands DOC list all COMMANDs for DOCUMENT DOC; use 'all' to list all
29-
-i, --inherited include inherited members in reference manual; may be slow, may fail for PDF output
30-
-u, --underscore include variables prefixed with '_' in reference
31-
manual; may be slow, may fail for PDF output
32-
-j, --mathjax, --jsmath ignored for backwards compatibility
33-
--no-plot do not include graphics auto-generated using the '.. plot' markup
34-
--include-tests-blocks include TESTS blocks in the reference manual
35-
--no-pdf-links do not include PDF links in DOCUMENT 'website';
36-
FORMATs: html, json, pickle, web
37-
--warn-links issue a warning whenever a link is not properly
38-
resolved; equivalent to '--sphinx-opts -n' (sphinx option: nitpicky)
39-
--check-nested check picklability of nested classes in DOCUMENT 'reference'
40-
--no-prune-empty-dirs do not prune empty directories in the documentation sources
41-
-N, --no-colors do not color output; does not affect children
42-
-q, --quiet work quietly; same as --verbose=0
43-
-v LEVEL, --verbose LEVEL report progress at LEVEL=0 (quiet), 1 (normal), 2
44-
(info), or 3 (debug); does not affect children
45-
-o DIR, --output DIR if DOCUMENT is a single file ('file=...'), write output to this directory
24+
-h, --help show a help message and exit
25+
-H, --help-all show an extended help message and exit
26+
-D, --documents list all available DOCUMENTs
27+
-F, --formats list all output FORMATs
28+
-C DOC, --commands DOC
29+
list all COMMANDs for DOCUMENT DOC; use 'all' to list all
30+
-i, --inherited include inherited members in reference manual; may be
31+
slow, may fail for PDF output
32+
-u, --underscore include variables prefixed with '_' in reference
33+
manual; may be slow, may fail for PDF output
34+
-j, --mathjax, --jsmath
35+
ignored for backwards compatibility
36+
--no-plot do not include graphics auto-generated using the '.. plot' markup
37+
--no-preparsed-examples
38+
do not show preparsed versions of EXAMPLES blocks
39+
--include-tests-blocks
40+
include TESTS blocks in the reference manual
41+
--no-pdf-links do not include PDF links in DOCUMENT 'website';
42+
FORMATs: html, json, pickle, web
43+
--live-doc make Sage code blocks live for html FORMAT
44+
--warn-links issue a warning whenever a link is not properly
45+
resolved; equivalent to '--sphinx-opts -n' (sphinx
46+
option: nitpicky)
47+
--check-nested check picklability of nested classes in DOCUMENT 'reference'
48+
--no-prune-empty-dirs
49+
do not prune empty directories in the documentation sources
50+
--use-cdns assume internet connection and use CDNs; in particular,
51+
use MathJax CDN
52+
-N, --no-colors do not color output; does not affect children
53+
-q, --quiet work quietly; same as --verbose=0
54+
-v LEVEL, --verbose LEVEL
55+
report progress at LEVEL=0 (quiet), 1 (normal), 2
56+
(info), or 3 (debug); does not affect children
57+
-o DIR, --output DIR if DOCUMENT is a single file ('file=...'), write output
58+
to this directory
4659
4760
Advanced options::
4861
49-
-S OPTS, --sphinx-opts OPTS pass comma-separated OPTS to sphinx-build; must
50-
precede OPTS with '=', as in '-S=-q,-aE' or '-S="-q,-aE"'
51-
-U, --update-mtimes before building reference manual, update
52-
modification times for auto-generated reST files
53-
-k, --keep-going do not abort on errors but continue as much as
54-
possible after an error
55-
--all-documents ARG if ARG is 'reference', list all subdocuments of
56-
en/reference. If ARG is 'all', list all main documents
57-
62+
Use these options with care.
63+
64+
-S OPTS, --sphinx-opts OPTS
65+
pass comma-separated OPTS to sphinx-build; must precede
66+
OPTS with '=', as in '-S=-q,-aE' or '-S="-q,-aE"'
67+
-U, --update-mtimes before building reference manual, update modification
68+
times for auto-generated reST files
69+
-k, --keep-going Do not abort on errors but continue as much as possible
70+
after an error
71+
--all-documents ARG if ARG is 'reference', list all subdocuments of
72+
en/reference. If ARG is 'all', list all main documents
5873
"""
5974

6075
import logging
@@ -69,6 +84,7 @@
6984

7085
logger = logging.getLogger(__name__)
7186

87+
7288
def format_columns(lst, align='<', cols=None, indent=4, pad=3, width=80):
7389
"""
7490
Utility function that formats a list as a simple table and returns

src/sage_docbuild/builders.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -867,20 +867,10 @@ def get_sphinx_environment(self):
867867
"""
868868
Return the Sphinx environment for this project.
869869
"""
870-
class FakeConfig():
871-
values = tuple()
872-
873-
class FakeApp():
874-
def __init__(self, dir):
875-
self.srcdir = dir
876-
self.config = FakeConfig()
877-
878870
env_pickle = os.path.join(self._doctrees_dir(), 'environment.pickle')
879871
try:
880872
with open(env_pickle, 'rb') as f:
881873
env = pickle.load(f)
882-
env.app = FakeApp(self.dir)
883-
env.config.values = env.app.config.values
884874
logger.debug("Opened Sphinx environment: %s", env_pickle)
885875
return env
886876
except (OSError, EOFError) as err:
@@ -897,29 +887,14 @@ def update_mtimes(self):
897887
for doc in env.all_docs:
898888
env.all_docs[doc] = time.time()
899889
logger.info("Updated %d reST file mtimes", len(env.all_docs))
890+
900891
# This is the only place we need to save (as opposed to
901892
# load) Sphinx's pickle, so we do it right here.
902-
env_pickle = os.path.join(self._doctrees_dir(),
903-
'environment.pickle')
904-
905-
# When cloning a new branch (see
906-
# SAGE_LOCAL/bin/sage-clone), we hard link the doc output.
907-
# To avoid making unlinked, potentially inconsistent
908-
# copies of the environment, we *don't* use
909-
# env.topickle(env_pickle), which first writes a temporary
910-
# file. We adapt sphinx.environment's
911-
# BuildEnvironment.topickle:
893+
env_pickle = os.path.join(self._doctrees_dir(), 'environment.pickle')
912894

913895
# remove unpicklable attributes
914896
env.set_warnfunc(None)
915-
del env.config.values
916897
with open(env_pickle, 'wb') as picklefile:
917-
# remove potentially pickling-problematic values from config
918-
for key, val in vars(env.config).items():
919-
if key.startswith('_') or isinstance(val, (types.ModuleType,
920-
types.FunctionType,
921-
type)):
922-
del env.config[key]
923898
pickle.dump(env, picklefile, pickle.HIGHEST_PROTOCOL)
924899

925900
logger.debug("Saved Sphinx environment: %s", env_pickle)

src/sage_docbuild/conf.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -820,26 +820,15 @@ def find_sage_dangling_links(app, env, node, contnode):
820820
'frozenset', 'int', 'list', 'long', 'object',
821821
'set', 'slice', 'str', 'tuple', 'type', 'unicode', 'xrange']
822822

823-
# Nit picky option configuration: Put here broken links we want to ignore. For
823+
824+
# nitpicky option configuration: Put here broken links we want to ignore. For
824825
# link to the Python documentation several links where broken because there
825826
# where class listed as functions. Expand the list 'base_class_as_func' above
826827
# instead of marking the link as broken.
827828
nitpick_ignore = [
828829
('py:class', 'twisted.web2.resource.Resource'),
829830
('py:class', 'twisted.web2.resource.PostableResource')]
830831

831-
def nitpick_patch_config(app):
832-
"""
833-
Patch the default config for nitpicky
834-
835-
Calling path_config ensure that nitpicky is not considered as a Sphinx
836-
environment variable but rather as a Sage environment variable. As a
837-
consequence, changing it doesn't force the recompilation of the entire
838-
documentation.
839-
"""
840-
app.config.values['nitpicky'] = (False, 'sage')
841-
app.config.values['nitpick_ignore'] = ([], 'sage')
842-
843832

844833
skip_picklability_check_modules = [
845834
#'sage.misc.test_nested_class', # for test only
@@ -1055,7 +1044,6 @@ def setup(app):
10551044
# in find_sage_dangling_links.
10561045
# app.connect('missing-reference', missing_reference)
10571046
app.connect('missing-reference', find_sage_dangling_links)
1058-
app.connect('builder-inited', nitpick_patch_config)
10591047
app.connect('html-page-context', add_page_context)
10601048

10611049

0 commit comments

Comments
 (0)