@@ -135,15 +135,8 @@ $(subst __,_,$(patsubst $(DOCS_DIR)/rabbitmq%.1.xml, src/rabbit_%_usage.erl, $(s
135135endef
136136
137137DOCS_DIR = docs
138- MANPAGES = $(patsubst % .xml, % , $(wildcard $(DOCS_DIR ) /* .[0-9].xml) )
139- WEB_MANPAGES = $(patsubst % .xml, % .man.xml, $(wildcard $(DOCS_DIR ) /* .[0-9].xml) $(DOCS_DIR ) /rabbitmq-service.xml $(DOCS_DIR ) /rabbitmq-echopid.xml)
140- USAGES_XML = $(DOCS_DIR ) /rabbitmqctl.1.xml $(DOCS_DIR ) /rabbitmq-plugins.1.xml
141- USAGES_ERL = $(foreach XML, $(USAGES_XML ) , $(call usage_xml_to_erl, $(XML ) ) )
142-
143- EXTRA_SOURCES += $(USAGES_ERL )
144-
145- .DEFAULT_GOAL = all
146- $(PROJECT ) .d :: $(EXTRA_SOURCES )
138+ MANPAGES = $(wildcard $(DOCS_DIR ) /* .[0-9])
139+ WEB_MANPAGES = $(patsubst % ,% .html,$(MANPAGES ) )
147140
148141DEP_PLUGINS = rabbit_common/mk/rabbitmq-build.mk \
149142 rabbit_common/mk/rabbitmq-dist.mk \
@@ -207,10 +200,7 @@ copy-escripts:
207200 PREFIX=" $( abspath $( CLI_ESCRIPTS_DIR) ) " \
208201 DESTDIR=
209202
210- clean :: clean-extra-sources clean-escripts
211-
212- clean-extra-sources :
213- $(gen_verbose ) rm -f $(EXTRA_SOURCES )
203+ clean :: clean-escripts
214204
215205clean-escripts :
216206 $(gen_verbose ) rm -rf " $( CLI_ESCRIPTS_DIR) "
@@ -219,45 +209,6 @@ clean-escripts:
219209# Documentation.
220210# --------------------------------------------------------------------
221211
222- # xmlto can not read from standard input, so we mess with a tmp file.
223- % : % .xml $(DOCS_DIR ) /examples-to-end.xsl
224- $(gen_verbose ) xmlto --version | \
225- grep -E ' ^xmlto version 0\.0\.([0-9]|1[1-8])$$' > /dev/null || \
226- opt=' --stringparam man.indent.verbatims=0' ; \
227- xsltproc --novalid $(DOCS_DIR ) /examples-to-end.xsl $< > $< .tmp && \
228- xmlto -vv -o $(DOCS_DIR ) $$ opt man $< 2>&1 | (grep -v ' ^Note: Writing' || :) && \
229- awk -F" 'u " ' /^\.HP / { print $$1; print $$2; next; } { print; }' " $@ " > " $@ .tmp" && \
230- mv " $@ .tmp" " $@ " && \
231- test -f $@ && \
232- rm $< .tmp
233-
234- # Use tmp files rather than a pipeline so that we get meaningful errors
235- # Do not fold the cp into previous line, it's there to stop the file being
236- # generated but empty if we fail
237- define usage_dep
238- $(call usage_xml_to_erl, $(1 ) ) :: $(1 ) $(DOCS_DIR ) /usage.xsl
239- $$(gen_verbose ) xsltproc --novalid --stringparam modulename "`basename $$@ .erl`" \
240- $(DOCS_DIR ) /usage.xsl $$< > $$@ .tmp && \
241- sed -e 's/"/\\"/g' -e 's/%QUOTE%/"/g' $$@ .tmp > $$@ .tmp2 && \
242- fold -s $$@ .tmp2 > $$@ .tmp3 && \
243- mv $$@ .tmp3 $$@ && \
244- rm $$@ .tmp $$@ .tmp2
245- endef
246-
247- $(foreach XML,$(USAGES_XML),$(eval $(call usage_dep, $(XML))))
248-
249- # We rename the file before xmlto sees it since xmlto will use the name of
250- # the file to make internal links.
251- % .man.xml : % .xml $(DOCS_DIR ) /html-to-website-xml.xsl
252- $(gen_verbose ) cp $< ` basename $< .xml` .xml && \
253- xmlto xhtml-nochunks ` basename $< .xml` .xml ; \
254- rm ` basename $< .xml` .xml && \
255- cat ` basename $< .xml` .html | \
256- xsltproc --novalid $(DOCS_DIR ) /remove-namespaces.xsl - | \
257- xsltproc --novalid --stringparam original ` basename $< ` $(DOCS_DIR ) /html-to-website-xml.xsl - | \
258- xmllint --format - > $@ && \
259- rm ` basename $< .xml` .html
260-
261212.PHONY : manpages web-manpages distclean-manpages
262213
263214docs :: manpages web-manpages
@@ -268,9 +219,32 @@ manpages: $(MANPAGES)
268219web-manpages : $(WEB_MANPAGES )
269220 @:
270221
222+ # We use mandoc(1) to convert manpages to HTML plus an awk script which
223+ # does:
224+ # 1. remove tables at the top and the bottom (they recall the
225+ # manpage name, section and date)
226+ # 2. "downgrade" headers by one level (eg. h1 -> h2)
227+ # 3. annotate .Dl lines with more CSS classes
228+ % .html : %
229+ $(gen_verbose ) mandoc -T html -O ' fragment,man=%N.%S.html' " $<" | \
230+ awk ' \
231+ /^< table class=" head" > $$ / { remove_table=1; next; } \
232+ /^< table class=" foot" > $$ / { remove_table=1; next; } \
233+ /^< \/ table> $$ / { if (remove_table) { remove_table=0; next; } } \
234+ { if (! remove_table) { \
235+ line=$$ 0; \
236+ gsub(/< h2/, " <h3" , line); \
237+ gsub(/< \/ h2> /, " </h3>" , line); \
238+ gsub(/< h1/, " <h2" , line); \
239+ gsub(/< \/ h1> /, " </h2>" , line); \
240+ gsub(/class=" D1" /, " class=\" D1 sourcecode bash hljs\" " , line); \
241+ print line; \
242+ } } \
243+ ' > "$@"
244+
271245distclean :: distclean-manpages
272246
273247distclean-manpages ::
274- $(gen_verbose ) rm -f $(MANPAGES ) $( WEB_MANPAGES )
248+ $(gen_verbose ) rm -f $(WEB_MANPAGES )
275249
276250app-build : copy-escripts
0 commit comments