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