doc/Makefile
author Pierre-Yves David <pierre-yves.david@octobus.net>
Fri, 15 Nov 2024 16:24:39 +0100
branchstable
changeset 52261 5565cf1e2d5e
parent 52021 2a875530a023
permissions -rw-r--r--
packaging: remove the i686 wheel from the linux-wheels target It is currently broken.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43736
640bae94f2f3 cleanup: update references to /help/ that should now be /helptext/
Augie Fackler <augie@google.com>
parents: 42058
diff changeset
     1
SOURCES=$(notdir $(wildcard ../mercurial/helptext/*.[0-9].txt))
671
efa4a7e2f322 Move hgrc documentation out to its own man page, hgrc(5).
Bryan O'Sullivan <bos@serpentine.com>
parents: 465
diff changeset
     2
MAN=$(SOURCES:%.txt=%)
efa4a7e2f322 Move hgrc documentation out to its own man page, hgrc(5).
Bryan O'Sullivan <bos@serpentine.com>
parents: 465
diff changeset
     3
HTML=$(SOURCES:%.txt=%.html)
12921
6b6e7da9bccd doc/Makefile: docs now also depend on extensions
Martin Geisler <mg@aragost.com>
parents: 12841
diff changeset
     4
GENDOC=gendoc.py ../mercurial/commands.py ../mercurial/help.py \
43736
640bae94f2f3 cleanup: update references to /help/ that should now be /helptext/
Augie Fackler <augie@google.com>
parents: 42058
diff changeset
     5
	../mercurial/helptext/*.txt ../hgext/*.py ../hgext/*/__init__.py
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
     6
RUNRST=runrst
2233
3840cefa5222 Added install target.
wilde@trapperkeeper.sha-bang.de
parents: 1879
diff changeset
     7
PREFIX=/usr/local
4030
a48971ae1387 install man pages by default into $(PREFIX)/share/man not $(PREFIX)/man since the FHS puts them there
Jonathan Smith <https://issues.rpath.com/>
parents: 3908
diff changeset
     8
MANDIR=$(PREFIX)/share/man
44721
eb9026a84e83 make: drop the `-c` arg to `install` in the documentation makefile
Matt Harbison <matt_harbison@yahoo.com>
parents: 43736
diff changeset
     9
INSTALL=install -m 644
46817
dc101c236219 makefile: use Python 3 by default when building docs as well
Martin von Zweigbergk <martinvonz@google.com>
parents: 44721
diff changeset
    10
# Default to Python 3.
dc101c236219 makefile: use Python 3 by default when building docs as well
Martin von Zweigbergk <martinvonz@google.com>
parents: 44721
diff changeset
    11
#
dc101c236219 makefile: use Python 3 by default when building docs as well
Martin von Zweigbergk <martinvonz@google.com>
parents: 44721
diff changeset
    12
# Windows ships Python 3 as `python.exe`, which may not be on PATH.  py.exe is.
dc101c236219 makefile: use Python 3 by default when building docs as well
Martin von Zweigbergk <martinvonz@google.com>
parents: 44721
diff changeset
    13
ifeq ($(OS),Windows_NT)
dc101c236219 makefile: use Python 3 by default when building docs as well
Martin von Zweigbergk <martinvonz@google.com>
parents: 44721
diff changeset
    14
PYTHON?=py -3
dc101c236219 makefile: use Python 3 by default when building docs as well
Martin von Zweigbergk <martinvonz@google.com>
parents: 44721
diff changeset
    15
else
dc101c236219 makefile: use Python 3 by default when building docs as well
Martin von Zweigbergk <martinvonz@google.com>
parents: 44721
diff changeset
    16
PYTHON?=python3
dc101c236219 makefile: use Python 3 by default when building docs as well
Martin von Zweigbergk <martinvonz@google.com>
parents: 44721
diff changeset
    17
endif
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    18
13054
25200c7efe0f runrst: add RSTARGS Makefile variable to allow customization
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12921
diff changeset
    19
RSTARGS=
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    20
GENDOCARGS=
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    21
GENDOCCMD=$(PYTHON) gendoc.py $(GENDOCARGS)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    22
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    23
# Output directories for individual help pages.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    24
MANOUT=man
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    25
HTMLOUT=html
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    26
BUILDDIR=build
465
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
    27
19427
80983af366b5 doc: make i18n man and html
Takumi IINO <trot.thunder@gmail.com>
parents: 19426
diff changeset
    28
export HGENCODING=UTF-8
9971
fa99480d5135 doc/Makefile: ensure C locale
Martin Geisler <mg@lazybytes.net>
parents: 9703
diff changeset
    29
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    30
.PHONY: all man html install clean knownrefs
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    31
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    32
# Generate a list of hg commands and extensions.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    33
commandlist.txt: $(GENDOC)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    34
	${GENDOCCMD} commandlist > $@.tmp
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    35
	mv $@.tmp $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    36
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    37
topiclist.txt: $(GENDOC)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    38
	${GENDOCCMD} topiclist > $@.tmp
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    39
	mv $@.tmp $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    40
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    41
extensionlist.txt: $(GENDOC)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    42
	${GENDOCCMD} extensionlist > $@.tmp
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    43
	mv $@.tmp $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    44
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    45
# Build target for running runrst more easily by hand
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    46
knownrefs: commandlist.txt topiclist.txt extensionlist.txt
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    47
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    48
BUILDFILES=commandlist.txt topiclist.txt extensionlist.txt
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    49
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    50
# We want to generate a sub-Makefile that can build the RST/man/html doc for
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    51
# each hg command. Here are templates that we'll use to generate this
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    52
# sub-Makefile.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    53
HGCMDTPL=templates/cmdheader.txt
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    54
TOPICTPL=templates/topicheader.txt
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    55
EXTTPL=templates/extheader.txt
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    56
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    57
define RuleAllCommandsTemplate
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    58
HG_COMMANDS=$(1)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    59
all-commands: $$(HG_COMMANDS:%=$$(BUILDDIR)/hg-%.gendoc.txt)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    60
endef
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    61
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    62
define RuleAllTopicsTemplate
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    63
HG_TOPICS=$(1)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    64
all-topics: $$(HG_TOPICS:%=$$(BUILDDIR)/%.gendoc.txt)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    65
endef
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    66
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    67
define RuleAllExtensionsTemplate
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    68
HG_EXTENSIONS=$(1)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    69
all-extensions: $$(HG_EXTENSIONS:%=$$(BUILDDIR)/%.gendoc.txt)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    70
endef
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    71
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    72
define RuleCommandTemplate
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    73
$$(BUILDDIR)/hg-$C.gendoc.txt: $$(GENDOC) $$(HGCMDTPL)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    74
	mkdir -p $$(@D)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    75
	$${GENDOCCMD} cmd-$C > $$@.tmp
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    76
	mv $$@.tmp $$@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    77
endef
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    78
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    79
define RuleTopicTemplate
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    80
$$(BUILDDIR)/topic-$T.gendoc.txt: $$(GENDOC) $$(TOPICTPL)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    81
	mkdir -p $$(@D)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    82
	$${GENDOCCMD} topic-$T > $$@.tmp
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    83
	mv $$@.tmp $$@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    84
endef
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    85
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    86
define RuleExtensionTemplate
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    87
$$(BUILDDIR)/ext-$E.gendoc.txt: $$(GENDOC) $$(EXTTPL)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    88
	mkdir -p $$(@D)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    89
	$${GENDOCCMD} ext-$E > $$@.tmp
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    90
	mv $$@.tmp $$@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    91
endef
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    92
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    93
# Actually generate the sub-Makefile.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    94
# The $file function is only supported by GNU Make 4 and above.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    95
CommandsTopicsExtensions.mk: commandlist.txt topiclist.txt extensionlist.txt Makefile
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    96
ifeq (4.0,$(firstword $(sort $(MAKE_VERSION) 4.0)))
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    97
	$(file > $@.tmp,# Generated by Makefile)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    98
	$(file >> $@.tmp,$(call RuleAllCommandsTemplate,$(file < commandlist.txt)))
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
    99
	$(file >> $@.tmp,$(call RuleAllTopicsTemplate,$(file < topiclist.txt)))
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   100
	$(file >> $@.tmp,$(call RuleAllExtensionsTemplate,$(file < extensionlist.txt)))
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   101
	$(foreach C,$(file < commandlist.txt),$(file >> $@.tmp,$(RuleCommandTemplate)))
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   102
	$(foreach T,$(file < topiclist.txt),$(file >> $@.tmp,$(RuleTopicTemplate)))
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   103
	$(foreach E,$(file < extensionlist.txt),$(file >> $@.tmp,$(RuleExtensionTemplate)))
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   104
	mv $@.tmp $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   105
else
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   106
	@echo "You are running make ${MAKE_VERSION} but you need make 4.0 or above"
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   107
endif
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   108
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   109
BUILDFILES+=CommandsTopicsExtensions.mk
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   110
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   111
# Include the sub-Makefile that contains rules for generating each individual
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   112
# command/help-topic/extension help page. This sub-Makefile is created by the
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   113
# rule above (CommandsTopicsExtensions.mk) which in turn is created from the
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   114
# plain-text lists of commands/help-topics/extensions.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   115
#
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   116
# Any time the source code changes, these plain-text lists and this
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   117
# sub-Makefile will get regenerated. Make will then restart itself to take
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   118
# into account the rules inside the sub-Makefile.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   119
#
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   120
# We want to avoid doing all this work for targets that we know don't need it
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   121
# however. For example, running `make clean` would only generate these files
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   122
# in order to delete them immediately. As a result, we don't include the
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   123
# sub-Makefile (and therefore don't require generating it) if clean is one of
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   124
# the targets. This might not do what we want when other targets are specified
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   125
# but it's most likely what we want.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   126
ifeq (,$(filter clean,$(MAKECMDGOALS)))
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   127
-include CommandsTopicsExtensions.mk
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   128
endif
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   129
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   130
# If the sub-Makefile is available, add all the hg commands, help-topics, and
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   131
# extensions to the list of things to generate html and man pages for.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   132
#
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   133
# Naming convention:
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   134
# - commands: hg-foo (html and man)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   135
# - help topics: topic-foo (html), hgfoo (man)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   136
# - extensions: ext-foo (html), hgext-foo (man)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   137
#
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   138
# Man pages for commands are in section 1 (user commands), topics and 
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   139
# extensions are in section 7 (miscellanea)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   140
#
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   141
# NOTE: topics and extension are temporarily disabled for man pages because
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   142
# they make docutils' RST converter crash.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   143
ifdef HG_COMMANDS
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   144
HTML+=$(HG_COMMANDS:%=$(HTMLOUT)/hg-%.html)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   145
MAN+=$(HG_COMMANDS:%=$(MANOUT)/hg-%.1)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   146
endif
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   147
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   148
ifdef HG_TOPICS
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   149
HTML+=$(HG_TOPICS:%=$(HTMLOUT)/topic-%.html)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   150
#MAN+=$(HG_TOPICS:%=$(MANOUT)/hg%.7)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   151
endif
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   152
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   153
ifdef HG_EXTENSIONS
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   154
HTML+=$(HG_EXTENSIONS:%=$(HTMLOUT)/ext-%.html)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   155
#MAN+=$(HG_EXTENSIONS:%=$(MANOUT)/hgext-%.7)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   156
endif
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   157
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   158
# Also add the HTML index page
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   159
HTML+=$(HTMLOUT)/index.html
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   160
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   161
1006
b0e581438835 Generate html documentation by default, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 671
diff changeset
   162
all: man html
465
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
   163
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
   164
man: $(MAN)
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
   165
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
   166
html: $(HTML)
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
   167
41850
d80d48928eb1 setup: define build_doc command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34622
diff changeset
   168
# This logic is duplicated in setup.py:hgbuilddoc()
19426
e43184680461 doc: make man and html from translated documents
Takumi IINO <trot.thunder@gmail.com>
parents: 19425
diff changeset
   169
common.txt $(SOURCES) $(SOURCES:%.txt=%.gendoc.txt): $(GENDOC)
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   170
	${GENDOCCMD} "$(basename $@)" > $@.tmp
9444
2f7f6e43d52b doc/Makefile: do not create files in case of errors
Martin Geisler <mg@lazybytes.net>
parents: 9422
diff changeset
   171
	mv $@.tmp $@
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1689
diff changeset
   172
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   173
%: %.txt %.gendoc.txt common.txt $(RUNRST)
13054
25200c7efe0f runrst: add RSTARGS Makefile variable to allow customization
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12921
diff changeset
   174
	$(PYTHON) runrst hgmanpage $(RSTARGS) --halt warning \
9445
f0105f2c424c doc/Makefile: make rst2html and rst2man halt on warnings
Martin Geisler <mg@lazybytes.net>
parents: 9444
diff changeset
   175
	  --strip-elements-with-class htmlonly $*.txt $*
465
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
   176
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   177
%.html: %.txt %.gendoc.txt common.txt $(RUNRST)
13054
25200c7efe0f runrst: add RSTARGS Makefile variable to allow customization
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12921
diff changeset
   178
	$(PYTHON) runrst html $(RSTARGS) --halt warning \
9626
d1aa5393bef4 doc: add a style sheet to the generated HTML pages
Martin Geisler <mg@lazybytes.net>
parents: 9445
diff changeset
   179
	  --link-stylesheet --stylesheet-path style.css $*.txt $*.html
465
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
   180
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   181
# Rules for index page and individual command/help-topic/extension pages
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   182
# Because the naming isn't the same between html and man pages, we need to
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   183
# break down man pages rules a bit more.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   184
$(BUILDDIR)/index.gendoc.txt: $(GENDOC)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   185
	mkdir -p $(@D)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   186
	${GENDOCCMD} index > $@.tmp
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   187
	mv $@.tmp $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   188
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   189
$(MANOUT)/hg-%.1: $(BUILDDIR)/hg-%.gendoc.txt common.txt $(RUNRST)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   190
	mkdir -p $(@D)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   191
	$(PYTHON) runrst hgmanpage --hg-individual-pages $(RSTARGS) --halt warning \
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   192
	  --strip-elements-with-class htmlonly $(BUILDDIR)/hg-$*.gendoc.txt $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   193
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   194
$(MANOUT)/hg%.7: $(BUILDDIR)/topic-%.gendoc.txt common.txt $(RUNRST)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   195
	mkdir -p $(@D)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   196
	$(PYTHON) runrst hgmanpage --hg-individual-pages $(RSTARGS) --halt warning \
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   197
	  --strip-elements-with-class htmlonly $(BUILDDIR)/topic-$*.gendoc.txt $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   198
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   199
$(MANOUT)/hgext-%.7: $(BUILDDIR)/ext-%.gendoc.txt common.txt $(RUNRST)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   200
	mkdir -p $(@D)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   201
	$(PYTHON) runrst hgmanpage --hg-individual-pages $(RSTARGS) --halt warning \
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   202
	  --strip-elements-with-class htmlonly $(BUILDDIR)/ext-$*.gendoc.txt $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   203
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   204
$(HTMLOUT)/%.html: $(BUILDDIR)/%.gendoc.txt common.txt $(RUNRST)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   205
	mkdir -p $(@D)
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   206
	$(PYTHON) runrst html --hg-individual-pages $(RSTARGS) --halt warning \
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   207
	  --link-stylesheet --stylesheet-path style.css $(BUILDDIR)/$*.gendoc.txt $@
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   208
3872
9d7ac8613340 fix MANIFEST generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3269
diff changeset
   209
MANIFEST: man html
9401
2a5144687727 doc/Makefile: Don't show Makefile comments in output
Mads Kiilerich <mads@kiilerich.com>
parents: 9400
diff changeset
   210
# tracked files are already in the main MANIFEST
3872
9d7ac8613340 fix MANIFEST generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3269
diff changeset
   211
	$(RM) $@
12841
5fbc2c38a98f doc/Makefile: do not include hg.1.gendoc.txt in MANIFEST
Martin Geisler <mg@lazybytes.net>
parents: 12840
diff changeset
   212
	for i in $(MAN) $(HTML); do \
3872
9d7ac8613340 fix MANIFEST generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3269
diff changeset
   213
	  echo "doc/$$i" >> $@ ; \
9d7ac8613340 fix MANIFEST generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3269
diff changeset
   214
	done
9d7ac8613340 fix MANIFEST generation
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3269
diff changeset
   215
2233
3840cefa5222 Added install target.
wilde@trapperkeeper.sha-bang.de
parents: 1879
diff changeset
   216
install: man
3840cefa5222 Added install target.
wilde@trapperkeeper.sha-bang.de
parents: 1879
diff changeset
   217
	for i in $(MAN) ; do \
8822
1027da7d2fb9 doc: fix regexp for determining the man page section
Cédric Duval <cedricduval@free.fr>
parents: 8311
diff changeset
   218
	  subdir=`echo $$i | sed -n 's/^.*\.\([0-9]\)$$/man\1/p'` ; \
34622
b584ed1b225d build: make install in "/doc" failed if the destination dir contained spaces
muxator <a.mux@inwind.it>
parents: 19427
diff changeset
   219
	  mkdir -p "$(DESTDIR)$(MANDIR)"/$$subdir ; \
b584ed1b225d build: make install in "/doc" failed if the destination dir contained spaces
muxator <a.mux@inwind.it>
parents: 19427
diff changeset
   220
	  $(INSTALL) $$i "$(DESTDIR)$(MANDIR)"/$$subdir ; \
2233
3840cefa5222 Added install target.
wilde@trapperkeeper.sha-bang.de
parents: 1879
diff changeset
   221
	done
3840cefa5222 Added install target.
wilde@trapperkeeper.sha-bang.de
parents: 1879
diff changeset
   222
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   223
# The clean target explicitly doesn't bother with the sub-Makefile, so we don't
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   224
# know anything about all the command/topic/extension targets and files.
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   225
# $(HTML) only has the basic topics, so we need to delete $(HTMLOUT)/*.html and
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   226
# other similar files "by hand" here.
465
f8cb8d082d40 Add a doc makefile
mpm@selenic.com
parents:
diff changeset
   227
clean:
52021
2a875530a023 doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents: 46817
diff changeset
   228
	$(RM) $(MAN) $(HTML) common.txt $(SOURCES) MANIFEST *.gendoc.txt $(BUILDFILES) $(BUILDDIR)/*.gendoc.* $(HTMLOUT)/*.html