Skip to content

Commit

Permalink
man: support bringing your own go-md2man
Browse files Browse the repository at this point in the history
Set the GO_MD2MAN make variable to elide building go-md2man from
vendored sources and use the specified command instead.

Signed-off-by: Cory Snider <csnider@mirantis.com>
(cherry picked from commit edfde78)
Signed-off-by: Cory Snider <csnider@mirantis.com>
  • Loading branch information
corhere committed Aug 26, 2024
1 parent 56c5c23 commit d5b0342
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions man/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ mandir = $(prefix)/man
INSTALL = install
INSTALL_DATA = ${INSTALL} -m 644

# By default, the man pages are generated using a copy of go-md2man built from
# the vendored sources in this directory. This behavior can be overridden by
# setting the GO_MD2MAN variable to the name/path of an existing go-md2man
# binary.
GO_MD2MAN ?= .build/go-md2man

ALL_PAGES := $(wildcard *.*.md)

# Determine which manual sections we are generating pages for
Expand All @@ -14,8 +20,8 @@ sections := $(sort $(foreach page,$(ALL_PAGES:.md=),$(call man_section,$(page)))
# Dynamically generate pattern rules for each manual section
# so make knows how to build a target like man8/dockerd.8.
define MANPAGE_template
man$(1)/%.$(1): %.$(1).md .build/go-md2man | man$(1)
.build/go-md2man -in $$< -out $$@
man$(1)/%.$(1): %.$(1).md $(if $(findstring file,$(origin GO_MD2MAN)),$(GO_MD2MAN)) | man$(1)
$(GO_MD2MAN) -in $$< -out $$@
endef
$(foreach sec,$(sections),$(eval $(call MANPAGE_template,$(sec))))

Expand Down

0 comments on commit d5b0342

Please sign in to comment.