Skip to content

Commit 77d8c65

Browse files
Merge pull request #1201 from rabbitmq/convert-manpages-to-mdoc
docs: Convert manpages from DocBook to mdoc(7)
2 parents d1eecf2 + c0af14b commit 77d8c65

18 files changed

+2337
-3437
lines changed

.gitignore

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,8 @@
1919
/escript
2020
rabbit.d
2121

22-
# Generated sources files.
23-
src/rabbit_ctl_usage.erl
24-
src/rabbit_plugins_usage.erl
25-
2622
# Generated documentation.
27-
docs/rabbitmq-echopid.man.xml
28-
docs/rabbitmq-env.conf.5
29-
docs/rabbitmq-env.conf.5.man.xml
30-
docs/rabbitmq-plugins.1
31-
docs/rabbitmq-plugins.1.man.xml
32-
docs/rabbitmq-server.1
33-
docs/rabbitmq-server.1.man.xml
34-
docs/rabbitmq-service.man.xml
35-
docs/rabbitmqctl.1
36-
docs/rabbitmqctl.1.man.xml
37-
docs/*.tmp
23+
docs/*.html
3824

3925
# Dialyzer
4026
*.plt

Makefile

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,8 @@ $(subst __,_,$(patsubst $(DOCS_DIR)/rabbitmq%.1.xml, src/rabbit_%_usage.erl, $(s
135135
endef
136136

137137
DOCS_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

148141
DEP_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

215205
clean-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

263214
docs:: manpages web-manpages
@@ -268,9 +219,32 @@ manpages: $(MANPAGES)
268219
web-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+
271245
distclean:: distclean-manpages
272246

273247
distclean-manpages::
274-
$(gen_verbose) rm -f $(MANPAGES) $(WEB_MANPAGES)
248+
$(gen_verbose) rm -f $(WEB_MANPAGES)
275249

276250
app-build: copy-escripts

docs/examples-to-end.xsl

Lines changed: 0 additions & 93 deletions
This file was deleted.

docs/html-to-website-xml.xsl

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)