Commit 98b88db2 authored by Philip Withnall's avatar Philip Withnall Committed by Stefan Sauer

make: Generate an entities file on build containing PACKAGE variables

Users frequently want to substitute PACKAGE_VERSION into the build
documentation, but end up having to do entity substitutions and automake
integration for it themselves, which is tricky to get right.

Generate an entity file automatically on build, containing all the
PACKAGE_* variables. Use it in the default generated main XML file, so
that new modules using gtk-doc don’t have to worry about this any more.

https://bugzilla.gnome.org/show_bug.cgi?id=743182
parent 647d9fff
......@@ -165,7 +165,7 @@ GTK_DOC_V_XML=$(GTK_DOC_V_XML_$(V))
GTK_DOC_V_XML_=$(GTK_DOC_V_XML_$(AM_DEFAULT_VERBOSITY))
GTK_DOC_V_XML_0=@echo " DOC Building XML";
sgml-build.stamp: tmpl.stamp $(DOC_MODULE)-sections.txt $(srcdir)/tmpl/*.sgml $(expand_content_files)
sgml-build.stamp: tmpl.stamp $(DOC_MODULE)-sections.txt $(srcdir)/tmpl/*.sgml $(expand_content_files) xml/gtkdocentities.ent
-$(GTK_DOC_V_XML)chmod -R u+w $(srcdir) && _source_dir='' ; \
for i in $(DOC_SOURCE_DIR) ; do \
_source_dir="$${_source_dir} --source-dir=$$i" ; \
......@@ -176,6 +176,17 @@ sgml-build.stamp: tmpl.stamp $(DOC_MODULE)-sections.txt $(srcdir)/tmpl/*.sgml $(
sgml.stamp: sgml-build.stamp
@true
xml/gtkdocentities.ent: Makefile
$(GTK_DOC_V_XML)$(MKDIR_P) $(@D) && ( \
echo "<!ENTITY package \"$(PACKAGE)\">"; \
echo "<!ENTITY package_bugreport \"$(PACKAGE_BUGREPORT)\">"; \
echo "<!ENTITY package_name \"$(PACKAGE_NAME)\">"; \
echo "<!ENTITY package_string \"$(PACKAGE_STRING)\">"; \
echo "<!ENTITY package_tarname \"$(PACKAGE_TARNAME)\">"; \
echo "<!ENTITY package_url \"$(PACKAGE_URL)\">"; \
echo "<!ENTITY package_version \"$(PACKAGE_VERSION)\">"; \
) > $@
#### html ####
GTK_DOC_V_HTML=$(GTK_DOC_V_HTML_$(V))
......
......@@ -142,7 +142,7 @@ GTK_DOC_V_XML=$(GTK_DOC_V_XML_$(V))
GTK_DOC_V_XML_=$(GTK_DOC_V_XML_$(AM_DEFAULT_VERBOSITY))
GTK_DOC_V_XML_0=@echo " DOC Building XML";
sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files)
sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files) xml/gtkdocentities.ent
$(GTK_DOC_V_XML)_source_dir='' ; \
for i in $(DOC_SOURCE_DIR) ; do \
_source_dir="$${_source_dir} --source-dir=$$i" ; \
......@@ -153,6 +153,17 @@ sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DO
sgml.stamp: sgml-build.stamp
@true
xml/gtkdocentities.ent: Makefile
$(GTK_DOC_V_XML)$(MKDIR_P) $(@D) && ( \
echo "<!ENTITY package \"$(PACKAGE)\">"; \
echo "<!ENTITY package_bugreport \"$(PACKAGE_BUGREPORT)\">"; \
echo "<!ENTITY package_name \"$(PACKAGE_NAME)\">"; \
echo "<!ENTITY package_string \"$(PACKAGE_STRING)\">"; \
echo "<!ENTITY package_tarname \"$(PACKAGE_TARNAME)\">"; \
echo "<!ENTITY package_url \"$(PACKAGE_URL)\">"; \
echo "<!ENTITY package_version \"$(PACKAGE_VERSION)\">"; \
) > $@
#### html ####
GTK_DOC_V_HTML=$(GTK_DOC_V_HTML_$(V))
......
......@@ -384,6 +384,8 @@ EOF
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
[
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY % gtkdocentities SYSTEM "../xml/gtkdocentities.ent">
%gtkdocentities;
]>
EOF
}
......@@ -2648,11 +2650,11 @@ sub OutputBook {
${\( MakeDocHeader ("book") )}
<book id="index">
<bookinfo>
<title>$MODULE Reference Manual</title>
<title>&package_name; Reference Manual</title>
<releaseinfo>
for $MODULE [VERSION].
for &package_string;.
The latest version of this documentation can be found on-line at
<ulink role="online-location" url="http://[SERVER]/$MODULE/index.html">http://[SERVER]/$MODULE/</ulink>.
<ulink role="online-location" url="http://[SERVER]/&package_name;/index.html">http://[SERVER]/&package_name;/</ulink>.
</releaseinfo>
</bookinfo>
......@@ -3079,6 +3081,12 @@ sub MakeDocHeader {
my ($tag) = @_;
my $header = $doctype_header;
$header =~ s/<!DOCTYPE \w+/<!DOCTYPE $tag/;
# fix the path for book since this is one level up
if ($tag eq "book") {
$header =~ s#<!ENTITY % gtkdocentities SYSTEM \"../([a-zA-Z./]+)\">#<!ENTITY % gtkdocentities SYSTEM \"$1\">#;
}
return $header;
}
......
......@@ -127,7 +127,7 @@ $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)
#### xml ####
sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files)
sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files) xml/gtkdocentities.ent
@ts1=`cat ts`;ts2=`date $(TS_FMT)`;tsd=`echo $$ts2-$$ts1 | bc`; \
echo " DOC `$(DATE_FMT_CMD)$$tsd`: Building XML"
@_source_dir='' ; \
......@@ -142,6 +142,17 @@ sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DO
sgml.stamp: sgml-build.stamp
@true
xml/gtkdocentities.ent: Makefile
$(GTK_DOC_V_XML)$(MKDIR_P) $(@D) && ( \
echo "<!ENTITY package \"$(PACKAGE)\">"; \
echo "<!ENTITY package_bugreport \"$(PACKAGE_BUGREPORT)\">"; \
echo "<!ENTITY package_name \"$(PACKAGE_NAME)\">"; \
echo "<!ENTITY package_string \"$(PACKAGE_STRING)\">"; \
echo "<!ENTITY package_tarname \"$(PACKAGE_TARNAME)\">"; \
echo "<!ENTITY package_url \"$(PACKAGE_URL)\">"; \
echo "<!ENTITY package_version \"$(PACKAGE_VERSION)\">"; \
) > $@
#### html ####
html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment