diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-01-04 09:36:27 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-01-04 09:36:27 -0500 |
commit | 9e49746da303b8bcf20238d77c8728aab7da9c61 (patch) | |
tree | 4219a7eb2cced24751cbdd5286a927f9d6b90947 /gcc/config/pdp11 | |
parent | 05c99b1c7965f46f0ff17d5e8f4020a62c643ae5 (diff) | |
download | gcc-9e49746da303b8bcf20238d77c8728aab7da9c61.zip gcc-9e49746da303b8bcf20238d77c8728aab7da9c61.tar.gz gcc-9e49746da303b8bcf20238d77c8728aab7da9c61.tar.bz2 |
options: add gcc/regenerate-opt-urls.py
In r14-5118-gc5db4d8ba5f3de I added a mechanism to automatically add
URLs to quoted strings in diagnostics. This was based on a data table
mapping strings to URLs, with placeholder data covering various pragmas
and a couple of options.
The following patches add automatic URLification in our diagnostic
messages to mentions of *all* of our options in quoted strings, linking
to our HTML documentation.
For example, with these patches, given:
./xgcc -B. -S t.c -Wctad-maybe-unsupported
cc1: warning: command-line option ‘-Wctad-maybe-unsupported’ is valid for C++/ObjC++ but not for C
the quoted string '-Wctad-maybe-unsupported' gets automatically URLified
in a sufficiently modern terminal to:
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wctad-maybe-unsupported
Objectives:
- integrate with DOCUMENTATION_ROOT_URL
- integrate with the existing .opt mechanisms
- automate keeping the URLs up-to-date
- work with target-specific options based on current configuration
- work with lang-specific options based on current configuration
- keep autogenerated material separate from the human-maintained .opt
files
- no new build-time requirements (by using awk at build time)
- be maintainable
The approach is a new regenerate-opt-urls.py which:
- scrapes the generated HTML documentation finding anchors
for options,
- reads all the .opt files in the source tree
- for each .opt file, generates a .opt.urls file; for each
option in the .opt file it has either a UrlSuffix directives giving
the final part of the URL of that option's documentation (relative
to DOCUMENTATION_ROOT_URL), or a comment describing the problem.
regenerate-opt-urls.py is written in Python 3, and has unit tests.
I tested it with Python 3.8, and it probably works with earlier
releases of Python 3.
The .opt.urls files it generates become part of the source tree, and
would be regenerated by maintainers whenever new options are added.
Forgetting to update the files (or not having Python 3 handy) merely
means that URLs might be missing or out of date until someone else
regenerates them.
At build time, the .opt.urls are added to .opt files when regenerating
the optionslist file. A new "options-urls-cc-gen.awk" is run at build
time on the optionslist to generate a "options-urls.cc" file, and this
is then used by the gcc_urlifier class when emitting diagnostics.
Changed in v5:
- removed commented-out code
Changed in v4:
- added PER_LANGUAGE_OPTION_INDEXES
- added info to sourcebuild.texi on adding a new front end
- removed TODOs and out-of-date comment
Changed in v3:
- Makefile.in: added OPT_URLS_HTML_DEPS and a comment
Changed in v2:
- added convenience targets to Makefile for regenerating the .opt.urls
files, and for running unit tests for the generation code
- parse gdc and gfortran documentation, and create LangUrlSuffix_{lang}
directives for language-specific URLs.
- add documentation to sourcebuild.texi
gcc/ChangeLog:
* Makefile.in (OPT_URLS_HTML_DEPS): New.
(regenerate-opt-urls): New target.
(regenerate-opt-urls-unit-test): New target.
* doc/options.texi (Option properties): Add UrlSuffix and
description of regenerate-opt-urls.py. Add LangUrlSuffix_*.
* doc/sourcebuild.texi (Anatomy of a Language Front End): Add
reference to regenerate-opt-urls.py's PER_LANGUAGE_OPTION_INDEXES
and Makefile.in's OPT_URLS_HTML_DEPS.
(Anatomy of a Target Back End): Add
reference to regenerate-opt-urls.py's TARGET_SPECIFIC_PAGES.
* regenerate-opt-urls.py: New file.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/config/pdp11')
0 files changed, 0 insertions, 0 deletions