Skip to content

Commit

Permalink
options: add gcc/regenerate-opt-urls.py
Browse files Browse the repository at this point in the history
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 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>
  • Loading branch information
davidmalcolm authored and ouuleilei-bot committed Dec 14, 2023
1 parent c2d62cd commit 65e3c68
Show file tree
Hide file tree
Showing 4 changed files with 454 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gcc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3513,6 +3513,22 @@ $(build_htmldir)/gccinstall/index.html: $(TEXI_GCCINSTALL_FILES)
DESTDIR=$(@D) \
$(SHELL) $(srcdir)/doc/install.texi2html

# Regenerate the .opt.urls files from the generated html, and from the .opt
# files. Doing so requires all languages that have their own HTML manuals
# to be enabled.
.PHONY: regenerate-opt-urls
OPT_URLS_HTML_DEPS = $(build_htmldir)/gcc/Option-Index.html \
$(build_htmldir)/gdc/Option-Index.html \
$(build_htmldir)/gfortran/Option-Index.html

regenerate-opt-urls: $(srcdir)/regenerate-opt-urls.py $(OPT_URLS_HTML_DEPS)
$(srcdir)/regenerate-opt-urls.py $(build_htmldir) $(shell dirname $(srcdir))

# Run the unit tests for regenerate-opt-urls.py
.PHONY: regenerate-opt-urls-unit-test
regenerate-opt-urls-unit-test: $(OPT_URLS_HTML_DEPS)
$(srcdir)/regenerate-opt-urls.py $(build_htmldir) $(shell dirname $(srcdir)) --unit-test

MANFILES = doc/gcov.1 doc/cpp.1 doc/gcc.1 doc/gfdl.7 doc/gpl.7 \
doc/fsf-funding.7 doc/gcov-tool.1 doc/gcov-dump.1 \
$(if $(filter yes,@enable_lto@),doc/lto-dump.1)
Expand Down
26 changes: 26 additions & 0 deletions gcc/doc/options.texi
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,30 @@ This warning option corresponds to @code{cpplib.h} warning reason code
@var{CPP_W_Enum}. This should only be used for warning options of the
C-family front-ends.

@item UrlSuffix(@var{url_suffix})
Adjacent to each human-written @code{.opt} file in the source tree is
a corresponding file with a @code{.opt.urls} extension. These files
contain @code{UrlSuffix} directives giving the ending part of the URL
for the documentation of the option, such as:

@smallexample
Wabi-tag
UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-Wabi-tag)
@end smallexample

These URL suffixes are relative to @code{DOCUMENTATION_ROOT_URL}.

There files are generated from the @code{.opt} files and the generated
HTML documentation by @code{regenerate-opt-urls.py}, and should be
regenerated when adding new options, via manually invoking
@code{make regenerate-opt-urls}.

@item LangUrlSuffix_@var{lang}(@var{url_suffix})
In addition to @code{UrlSuffix} directives, @code{regenerate-opt-urls.py}
can generate language-specific URLs, such as:

@smallexample
LangUrlSuffix_D(gdc/Code-Generation.html#index-MMD)
@end smallexample

@end table
4 changes: 4 additions & 0 deletions gcc/doc/sourcebuild.texi
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,10 @@ options supported by this target (@pxref{Run-time Target, , Run-time
Target Specification}). This means both entries in the summary table
of options and details of the individual options.
@item
An entry in @file{gcc/regenerate-opt-urls.py}'s TARGET_SPECIFIC_PAGES
dictionary mapping from target-specific HTML documentation pages
to the target specific source directory.
@item
Documentation in @file{gcc/doc/extend.texi} for any target-specific
attributes supported (@pxref{Target Attributes, , Defining
target-specific uses of @code{__attribute__}}), including where the
Expand Down
Loading

0 comments on commit 65e3c68

Please sign in to comment.