Commit Graph

163 Commits

Author SHA1 Message Date
Brad King
8801ce34c1 Merge topic 'sphinx-docutils-warning' into release-3.27
0c14b6085a Utilities/Sphinx: Fix warning from docutils 0.18.1+

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8578
2023-06-23 10:46:29 -04:00
Henry Schreiner
0c14b6085a Utilities/Sphinx: Fix warning from docutils 0.18.1+
Also might fix 0.18.0 exactly, which apparently forgot to add the
backward compat shim.
2023-06-22 10:48:50 -04:00
Matthew Woehlke
f546ebfecc Utilities/Sphinx: Fix parallel documentation builds
In commit d78bfa1ecc (Utilities/Sphinx: support cmakedomain running in
parallel, 2022-10-24, v3.26.0-rc1~495^2) we declared the domain as
parallel-safe without actually implementing the required
`merge_domaindata` method.  Since then, commit 37e015d4a6
(Utilities/Sphinx: Refactor Sphinx reference recording) changed how we
store resolved references, such that our separate fix for 3.26 does not
work in 3.27+.

While at it, correct a crusty comment that was overlooked during the
aforementioned refactoring.

Issue: #24076
Co-authored-by: Jared Dillard <jared.dillard@gmail.com>
2023-06-22 10:02:43 -04:00
Matthew Woehlke
528cdc7551 Utilities/Sphinx: Fix some flake8 gripes
Reorder some imports to better conform to what flake8 wants.
2023-06-13 11:39:48 -04:00
Matthew Woehlke
4bd1beded4 Utilities/Sphinx: Don't ignore flake8 E402
Refactor commit 1f39a3cd1a (Utilities/Sphinx: Restore explicit check for
Sphinx 2.x or later) to avoid needing to suppress flake8 E402. While
ignoring it with respect to the docutils/sphinx imports and the sphinx
version check was correct, the need to disable it for the whole file was
suboptimal.
2023-06-13 11:25:14 -04:00
Brad King
1f39a3cd1a Utilities/Sphinx: Restore explicit check for Sphinx 2.x or later
Refactoring in commit adbc8c982d (Utilities/Sphinx: Fix flake8 gripes in
cmake.py, 2023-03-13, v3.27.0-rc1~317^2) moved the assertion added by
commit cef51925a4 (Utilities/Sphinx: Require Sphinx 2.x or later,
2023-03-13, v3.27.0-rc1~317^2~2) to after imports, which is too late to
clearly reject older Sphinx versions.
2023-06-12 17:37:13 -04:00
Brad King
5de805bea2 Utilities/Sphinx: Fix flake8 E124 diagnostic in cmake.py 2023-06-12 17:34:25 -04:00
Craig Scott
0de00b8b69 Sphinx: Modernize UTF-8 encoding handling when updating CMake.qhp 2023-04-07 18:14:18 +10:00
Craig Scott
f0d6010cb5 Sphinx: Specify encoding when opening files for title extraction
When the encoding is not specified, open() may choose an encoding
based on the locale in use. That encoding may have no relationship
to the encoding of the file being opened. Use the locale from the
document settings instead, which should better match the file's
encoding.

Fixes: #24679
2023-04-07 18:11:05 +10:00
Matthew Woehlke
adbc8c982d Utilities/Sphinx: Fix flake8 gripes in cmake.py
Edit Utilities/Sphinx/cmake.py to avoid lines longer than 79 characters
and to obey other flake8-checked style rules. This will allow using
flake8 to check for possible issues without having to wade through noise
about improper styling. (Also, of course, consistent styling is
beneficial in its own right.)
2023-03-15 10:53:10 -04:00
Matthew Woehlke
9fab1ad504 Utilities/Sphinx: Use f-strings in cmake.py
Port all uses of old-style % string formatting to use f-strings. These
are generally more readable (and tend to be shorter as well).

Although this requires Python 3.6 or later, that should be available
'stock' on most or all platforms still under support, and besides, we
were already using f-strings in some places.
2023-03-15 10:53:10 -04:00
Matthew Woehlke
cef51925a4 Utilities/Sphinx: Require Sphinx 2.x or later
Tweak our Sphinx extensions slightly to assert that Sphinx is at least
2.x. Remove hacks for older versions of Sphinx. This cleans up a bunch
of messy code and, more importantly, paves the way for consolidating our
import statements.
2023-03-15 10:53:10 -04:00
Matthew Woehlke
302f5171d8 Utilities/Sphinx: Add 'cref' role
Add a role that can be used to create local links (a la '`LINK`_'), but
that also applies literal style. This is particularly useful for
referring to subcommands within the command's documentation in a style
that is consistent with ':command:`BAR <foo(BAR)>`' but is much less
verbose.

Although this is intended for subcommands, it works with any local
reference.

Co-authored-by: Brad King <brad.king@kitware.com>
2023-03-14 15:20:47 -04:00
Matthew Woehlke
bc77ddb90c Utilities/Sphinx: Factor out part of CMakeXRefRole
Refactor the portion of CMakeXRefRole that escapes angle brackets in
reference titles to the equivalent of a C++ template class. This will
allow us to reuse that logic for reference roles that aren't derived
from XRefRole.
2023-03-14 15:13:38 -04:00
Brad King
ec8dff789f Merge topic 'version-hanging-indent'
038f4c12e3 Utilities/Sphinx: Add hanging indent to version notes

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8325
2023-03-14 15:07:18 -04:00
Matthew Woehlke
038f4c12e3 Utilities/Sphinx: Add hanging indent to version notes
Tweak HTML styling of version-{added,changed} notes to include a hanging
indent. This makes it more obvious what text is part of such a note in
cases where the note is lengthy (especially if more than one paragraph),
rather than the relevant text blending into the surrounding prose.
2023-03-14 14:39:44 -04:00
Brad King
c8679f0571 Utilities/Sphinx: Restore trailing parens on command cross-references
Since commit cc21d0e478 (Utilities/Sphinx: Make signatures linkable,
2023-03-09) we always convert `cmake:command` domain cross-references to
use the explicit `text <text>` form.  This breaks the XRefRole's
`fix_parens` setting that we use to render `cmd` as `cmd()`.
Instead, transform `cmd(sub)` to `cmd(sub) <cmd(sub)>` to preserve
the sub-command link destination, but leave `cmd` alone and let
XRefRole convert it to `cmd()`.
2023-03-14 14:33:02 -04:00
Brad King
08d31c227b Merge topic 'smart-wrap-signatures'
39ecaa5da1 Utilities/Sphinx: Improve word wrap of signatures

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8317
2023-03-14 09:39:52 -04:00
Matthew Woehlke
2e37a20f02 Utilities/Sphinx: Allow explicit target for genex
Split the genex directive into its own class, allowing a slight
simplification of CMakeObject. Add ability to specify an explicit target
name for the same.

Use this to provide a target for the `$<TARGET_PROPERTY:prop>` generator
expression which is otherwise missing one (due to overlap with
`$<TARGET_PROPERTY:tgt,prop>`).  With this one can write:

    :genex:`$<TARGET_PROPERTY:prop> <TARGET_PROPERTY:prop>`

to link the second variant.

Fixes: #24573
2023-03-13 17:04:52 -04:00
Matthew Woehlke
39ecaa5da1 Utilities/Sphinx: Improve word wrap of signatures
Implement logic to support several styles of parsing in the new
signature directive that control where line breaks are allowed in a
signature.

The default is 'smart', which forbids breaks inside of square- or
angle-brackets. The 'verbatim' option forbids all breaks. In all cases,
breaks are always allowed where a newline appears in the source.

This seems to Just Work for most writers, but HTML needs some special
handling that is accomplished by a new CSS rule and assigning the 'nbsp'
class to spaces that are not allowed to break. (ROFF's line wrapping is
rather unfortunate here, as it prefers splitting and hyphenating words
rather than breaking at a space.)
2023-03-13 13:31:38 -04:00
Matthew Woehlke
cc21d0e478 Utilities/Sphinx: Make signatures linkable
Add signatures to the collection of observed objects (which can be
referenced elsewhere). Don't automatically strip parameters from a
:command: reference, as these may now link signatures. (Do, however,
munge them into 'text <ref>' form if they aren't already, as not doing
so adds an extra '()' for some reason.) Correspondingly, change xref
resolution to try to match 'command' when a ref like 'command(args)' is
not matched, so that existing links to commands that have not been
converted to use the new signature directive don't immediately break.
2023-03-09 11:32:07 -05:00
Matthew Woehlke
37e015d4a6 Utilities/Sphinx: Refactor Sphinx reference recording
Rewrite how we record objects in our Sphinx extensions to more closely
conform to how other domains do likewise, and to store more information
than was previously being stored.

This is a first step toward being able to record and reference
signatures.
2023-03-08 13:19:50 -05:00
Matthew Woehlke
74e3c1d313 Utilities/Sphinx: Add a directive to document command signatures
Add a `signature` directive to offer a CMake version of Sphinx's
`function` directive, similar to that found in other domains (py, cpp,
etc.).  Like others, this takes one or more signatures as arguments and
creates dt/dd nodes from the signatures and the directive contents.
2023-03-03 17:05:02 -05:00
Brad King
c09b760484 Utilities/Sphinx: Drop commented-out code from cmake domain impl
Inspired-by: Alex Turbov <i.zaufi@gmail.com>
2023-02-24 12:25:35 -05:00
Brad King
14506f49a2 Utilities/Sphinx: Configure linkcheck allowed permanent redirects
Some permanent redirects are part of the structure of their site
to make URLs look nicer.  Allow them.
2023-02-17 08:45:01 -05:00
Brad King
220fa1d92b Configure CMake itself with policies through CMake 3.25 2023-02-01 17:01:38 -05:00
Brad King
6834ffd21b Merge topic 'doc-guide-link-style'
977c38c339 Help: Render guide links as normal text instead of monospace

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7886
2022-11-09 09:29:53 -05:00
Alex Turbov
977c38c339 Help: Render guide links as normal text instead of monospace
The guide document names are phrases, not code-like man-page names.
Add CSS selectors for `:guide:` links and revert unnecessary properties.
2022-11-08 09:53:20 -05:00
Alex Turbov
a89c76a773 Build: Add SPHINX_LINKCHECK build option
Run `sphinx-build` to check external links and report broken one.
2022-11-07 10:10:23 -05:00
Alex Turbov
137b00cda1 Build: Do not redirect sphinx-build output if CMake running in verbose mode
Configuring with `--log-level=VERBOSE` a user can see an output of
`sphinx-build` at build time.

The other way is to have `VERBOSE` envvar set at configure time.

And finally one can set `CMAKE_VERBOSE_MAKEFILE` CMake cache variable.
2022-11-07 10:09:53 -05:00
Alex Turbov
d954fb8a60 Build: Deduplicate add_custom_command() calls for Sphinx targets 2022-11-07 10:09:46 -05:00
Henry Schreiner
d78bfa1ecc Utilities/Sphinx: support cmakedomain running in parallel
Fixes: #24076

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-10-24 18:03:11 -04:00
Brad King
5f998bbcb3 Configure CMake itself with policies through CMake 3.24 2022-10-12 12:43:27 -04:00
Brad King
294b6db533 Utilities/Sphinx: Avoid deprecated docutils error handling helpers
The `SafeString` and `ErrorString` classes are deprecated and will be
removed in Docutils 0.21 or later.  They help avoid encoding errors
during exception handling in Python <= 2.7, but these days we always
use Python 3 to build the documentation, at least during development,
when error cases are most likely to occur.

Fixes: #24039
2022-10-11 10:01:12 -04:00
Alex Turbov
a509602699 Build: Modernize some foreach calls to use IN LISTS/IN ITEMS 2022-09-22 09:24:46 -04:00
FeRD (Frank Dana)
ff2e7ceb66 QtHelp: Update Sphinx issue URLs in comments
The QtHelp Sphinx generation code contains two links to Sphinx issues
that used old, dead BitBucket URLs. Those issues were migrated to
GitHub, so the dead links can be replaced with working ones.
2022-09-04 22:59:00 +10:00
Brad King
ac24f4d49b Configure CMake itself with policies through CMake 3.23 2022-06-14 15:05:09 -04:00
Brad King
756e83fbe2 Merge topic 'doc-cmake.org-tutorial-archive'
4cb616fed6 Tutorial: Provide a source archive when published on cmake.org
37fb70591e Utilities/Sphinx: Add variables listing pre-sphinx commands
eb7d913a21 Utilities/Sphinx: Clarify names of variables listing post-sphinx commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7215
2022-04-29 09:26:17 -04:00
Brad King
4cb616fed6 Tutorial: Provide a source archive when published on cmake.org
Provide readers following the tutorial on `cmake.org` a direct link to
download the tutorial's source examples.  Previously readers had to
fetch the CMake source tree separately and look for the tutorial source
examples inside it.

Fixes: #22475
2022-04-28 13:36:20 -04:00
Brad King
37fb70591e Utilities/Sphinx: Add variables listing pre-sphinx commands 2022-04-27 15:22:31 -04:00
Brad King
eb7d913a21 Utilities/Sphinx: Clarify names of variables listing post-sphinx commands 2022-04-27 15:22:31 -04:00
Kyle Edwards
313ea361b0 CMake: Use FindPython instead of FindPythonInterp to build CMake itself
Fixes: #23444
2022-04-21 14:23:36 -04:00
Brad King
de6038aaf4 Merge branch 'doc-qhelpgenerator' into release-3.23
Merge-request: !7150
2022-04-08 08:52:55 -04:00
Brad King
261b29bccc Merge topic 'doc-qhelpgenerator'
bf69fa32c4 Utilities/Sphinx: Update qthelp generation to qhelpgenerator
37904abb58 Help: Add "Updates" section header in 3.22 release notes

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7150
2022-04-08 08:51:22 -04:00
Brad King
bf69fa32c4 Utilities/Sphinx: Update qthelp generation to qhelpgenerator
`qcollectiongenerator` is deprecated in favor of `qhelpgenerator`.
2022-04-07 09:37:37 -04:00
Brad King
5c429c5b40 Merge topic 'ci-cmake.org-help'
b691906d27 gitlab-ci: Build qthelp-format release documentation for cmake.org
1ceec19c20 gitlab-ci: Add objects.inv to cmake.org html documentation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7146
2022-04-06 13:02:38 -04:00
Brad King
76632f9f47 Merge topic 'ci-cmake.org-help' into release-3.23
b691906d27 gitlab-ci: Build qthelp-format release documentation for cmake.org
1ceec19c20 gitlab-ci: Add objects.inv to cmake.org html documentation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7146
2022-04-06 13:02:37 -04:00
Brad King
b691906d27 gitlab-ci: Build qthelp-format release documentation for cmake.org
Previously the qthelp-format release documentation on `cmake.org` was
built manually.
2022-04-06 09:59:14 -04:00
Brad King
f38fbdb65b Merge topic 'ci-cmake.org-help' into release-3.23
2808281730 gitlab-ci: update cmake.org documentation in release package pipeline
ed00a29cce gitlab-ci: consolidate jobs for cmake.org/cmake/help/git-{master,stage} docs
5c2e8ce515 Utilities/Sphinx: Add OpenSearch link to html page headers on cmake.org
a14905d4df Utilities/Sphinx: Add option to build outdated version banner for cmake.org
cca73b54ae Utilities/Sphinx: Add undocumented option to build docs for cmake.org

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7144
2022-04-05 17:46:01 -04:00
Brad King
2ce668b11d Merge branch 'backport-ci-cmake.org-help' into ci-cmake.org-help 2022-04-05 16:51:04 -04:00