Skip to content

Commit 5750f9f

Browse files
author
Sam Kleinman
committed
build: making the builder interface more clear.
1 parent f98a583 commit 5750f9f

File tree

3 files changed

+45
-34
lines changed

3 files changed

+45
-34
lines changed

bin/makefile_builder.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,25 @@ def section_break(self, name):
2222
def comment(self, comment):
2323
self.makefile.append('\n# ' + comment + '\n')
2424

25-
def target(self, target):
26-
self.makefile.append(target + '\n')
25+
def target(self, target, dependency):
26+
self.makefile.append(target + ':' + dependency + '\n')
2727

2828
def var(self, variable, value):
2929
self.makefile.append(variable + ' = ' + value + '\n')
3030

3131
def append_var(self, variable, value):
3232
self.makefile.append(variable + ' += ' + value + '\n')
3333

34-
def job(self, job):
35-
self.makefile.append('\t' + job + '\n')
34+
def job(self, job, display=False):
35+
if display is True:
36+
o = '\t' + job + '\n'
37+
else:
38+
o = '\t@' + job + '\n'
39+
40+
self.makefile.append(o)
41+
42+
def message(self, message):
43+
self.makefile.append('\t@echo ' + message + '\n')
3644

3745
def print_content(self):
3846
for line in self.makefile:

bin/pdf_makefile_builder.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,31 @@
1313
def makefile_builder(name, tag):
1414
name_tagged = name + '-' + tag
1515

16-
content = MakefileBuilder()
16+
m = MakefileBuilder()
1717

18-
content.section_break(name)
19-
content.target('$(branch-output)/latex/' + name + '.tex:latex')
20-
content.job('@sed $(SED_ARGS_FILE) -e $(LATEX_CORRECTION) -e $(LATEX_CORRECTION) -e $(LATEX_LINK_CORRECTION) $@')
21-
content.job('@echo [latex]: fixing $@ TeX from the Sphinx output.')
18+
m.section_break(name)
19+
m.target(target='$(branch-output)/latex/' + name + '.tex',
20+
dependency='latex')
21+
m.job('sed $(SED_ARGS_FILE) -e $(LATEX_CORRECTION) -e $(LATEX_CORRECTION) -e $(LATEX_LINK_CORRECTION) $@')
22+
m.message('[latex]: fixing $@ TeX from the Sphinx output.')
2223

23-
content.target('$(branch-output)/latex/' + name_tagged + '.tex:$(branch-output)/latex/' + name + '.tex')
24-
content.job('@$(PYTHONBIN) bin/copy-if-needed.py -i $< -o $@ -b pdf')
24+
m.target(target='$(branch-output)/latex/' + name_tagged + '.tex',
25+
dependency='$(branch-output)/latex/' + name + '.tex')
26+
m.job('$(PYTHONBIN) $(build-tools)/copy-if-needed.py -i $< -o $@ -b pdf')
2527

26-
content.target('$(public-branch-output)/' + name_tagged + '-$(current-branch).pdf:$(branch-output)/latex/' + name_tagged + '.pdf')
27-
content.job('@cp $< $@')
28-
content.job('@echo [build]: migrated $@')
28+
m.target(target='$(public-branch-output)/' + name_tagged + '-$(current-branch).pdf',
29+
dependency='$(branch-output)/latex/' + name_tagged + '.pdf')
30+
m.job('cp $< $@')
31+
m.message('[build]: migrated $@')
2932

30-
content.target('$(public-branch-output)/' + name_tagged + '.pdf:$(public-branch-output)/' + name_tagged + '-$(current-branch).pdf')
31-
content.job('@bin/create-link $(notdir $<) $(notdir $@) $@')
33+
m.target(target='$(public-branch-output)/' + name_tagged + '.pdf',
34+
dependency='$(public-branch-output)/' + name_tagged + '-$(current-branch).pdf')
35+
m.job('$(build-tools)/create-link $(notdir $<) $(notdir $@) $@')
3236

33-
content.comment('adding ' + name + '.pdf to the build dependency.')
34-
content.append_var('PDF_OUTPUT', '$(public-branch-output)/' + name_tagged + '.pdf')
37+
m.comment('adding ' + name + '.pdf to the build dependency.')
38+
m.append_var('PDF_OUTPUT', '$(public-branch-output)/' + name_tagged + '.pdf')
3539

36-
return content.makefile
40+
return m.makefile
3741

3842
class MongoDBManualPdfMakefile(object):
3943
def __init__(self, makefile=[]):

makefile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include bin/makefile.tables
99

1010
# Build directory tweaking.
1111
output = build
12+
build-tools = bin
1213
public-output = $(output)/public
1314
branch-output = $(output)/$(current-branch)
1415
public-branch-output = $(public-output)/$(current-branch)
@@ -43,24 +44,22 @@ ALLSPHINXOPTS = -q -d $(branch-output)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPT
4344
POSPHINXOPTS = -q -d $(branch-output)/doctrees-gettext $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
4445
DRAFTSPHINXOPTS = -q -d $(branch-output)/draft-doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) draft
4546

46-
4747
.PHONY: publish help clean push-dc1 push-dc2
48-
4948
help:
5049
@echo "Please use \`make <target>' where <target> is one of"
51-
@echo " html to make standalone HTML files"
52-
@echo " dirhtml to make HTML files named index.html in directories"
53-
@echo " singlehtml to make a single large HTML file"
54-
@echo " epub to make an epub"
55-
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
56-
@echo " man to make manual pages"
57-
@echo " changes to make an overview of all changed/added/deprecated items"
50+
@echo " html to make standalone HTML files"
51+
@echo " dirhtml to make HTML files named index.html in directories"
52+
@echo " singlehtml to make a single large HTML file"
53+
@echo " epub to make an epub"
54+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
55+
@echo " man to make manual pages"
56+
@echo " changes to make an overview of all changed/added/deprecated items"
5857
@echo
5958
@echo "MongoDB Manual Specific Targets."
60-
@echo " publish runs publication process and then deploys the build to $(public-output)"
61-
@echo " push runs publication process and pushes to docs site to production."
62-
@echo " draft builds a 'draft' build for pre-publication testing ."
63-
@echo " pdfs generates pdfs more efficently than latexpdf."
59+
@echo " publish runs publication process and then deploys the build to $(public-output)"
60+
@echo " push runs publication process and pushes to docs site to production."
61+
@echo " draft builds a 'draft' build for pre-publication testing ."
62+
@echo " pdfs generates pdfs more efficently than latexpdf."
6463
@echo
6564
@echo "See 'meta.build.rst' for more information."
6665

@@ -219,8 +218,8 @@ $(public-branch-output)/single/search.html:$(branch-output)/dirhtml/search/index
219218
$(public-branch-output)/single/index.html:$(branch-output)/singlehtml/contents.html
220219
@cp $< $@
221220
@sed $(SED_ARGS_FILE) -e 's/href="contents.html/href="index.html/g' \
222-
-e 's/name="robots" content="index"/name="robots" content="noindex"/g' \
223-
-e 's/(href=")genindex.html"/\1..\/genindex\/"/g' $@
221+
-e 's/name="robots" content="index"/name="robots" content="noindex"/g' \
222+
-e 's/(href=")genindex.html"/\1..\/genindex\/"/g' $@
224223
@echo [single]: generating and processing '$@' page
225224

226225
# Deployment related work for the non-Sphinx aspects of the build.

0 commit comments

Comments
 (0)