Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better document the build #666

Merged
merged 37 commits into from Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1320e2e
Better document the build
Feb 1, 2018
b673d74
Remove duplicate comments, use consistent order
Feb 1, 2018
727cc34
Add commands to build_pots.sh
Feb 1, 2018
903c1a9
Eliminate the Sphinx warning: "WARNING: image file not readable: impl…
Feb 1, 2018
af41b6d
Better organize requirements.txt and imports
Feb 2, 2018
6579a99
Use --editable for git packages
Feb 2, 2018
d085715
Strip leading and trailing whitespace from title and description valu…
Feb 2, 2018
40d07af
Update Babel configuration
Feb 2, 2018
a3d634e
Add missing requirement
Feb 2, 2018
d9155ce
Upgrade Sphinx to 1.5.6 and sphinx-intl to 0.9.10, to get e.g. sphinx…
Feb 2, 2018
7354758
Revert part of 1320e2e7cb33cbde96848c68f1255ec22bc86949 as can't proc…
Feb 2, 2018
efd2beb
Don't hardcode build directory in translate_schema.py
Feb 2, 2018
04e668b
Move stricter_validation.py to ocdskit
Feb 6, 2018
cc3df88
Try alternate deploy script
Feb 6, 2018
9625864
Use branch ref for alternate deploy script
Feb 6, 2018
b9d6e11
Replace build scripts with Makefile, build translated codelists in bu…
Feb 6, 2018
56e43f3
Fix cleanup in Makefile
Feb 6, 2018
1106541
Downgrade to Sphinx 1.5.1 again as 1.5.2 breaks translation of sideba…
Feb 6, 2018
7a94d2c
Replace build_docs.sh with make
Feb 6, 2018
9ef1c57
Switch back to main repos
Feb 6, 2018
1fe2561
Fix script URL
Feb 6, 2018
57128b9
Switch back to OpenDataServices deploy script
Feb 6, 2018
50051de
Test deploy with branch, add clean_current_lang prerequisite to extra…
Feb 6, 2018
07f5801
Move the compile Makefile target into conf.py, and make conf.py more …
Mar 21, 2018
9c6a8f8
Use shared code instead
Mar 21, 2018
0f36945
Update .gitignore
Mar 21, 2018
617b8fe
Merge branch '1.1-dev' into build
Mar 21, 2018
67b0348
Use ocds_documentation_support
Mar 22, 2018
9be44b0
Use requirements.txt structure of standard_profile_template
Mar 22, 2018
5d5e275
Update pytest and documentation-support
Mar 23, 2018
5b8ac0f
Move pybabel back out of conf.py
Mar 23, 2018
65a8f84
Reorder .travis.yml to match other repositories, and expand one-liner
Mar 23, 2018
aee2d7e
Split Makefile per standard_profile_template
Mar 23, 2018
4ed93d5
Update Makefiles
Mar 24, 2018
1e65945
Fix deploy script URL
Mar 24, 2018
931bd5c
Reset pytest to 2.8.7
Mar 24, 2018
a2c6463
Remove empty footer template and empty extrahead block
Mar 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .babel_codelists
@@ -0,0 +1,2 @@
[codelists_text: standard/schema/codelists/*.csv]
[codelists_text: standard/docs/en/extensions/codelists/*.csv]
1 change: 1 addition & 0 deletions .babel_schema
@@ -0,0 +1 @@
[jsonschema_text: standard/schema/*.json]
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -5,7 +5,5 @@
venv
.ve

/standard/schema/codelists_translated
/standard/docs/en/extensions/codelists_translated
/build
*.mo
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -14,11 +14,11 @@ install:
# command to run tests, e.g. python setup.py test
script:
- flake8
- ./build_docs.sh
- make
- py.test -rs --tb=line
deploy:
skip_cleanup: true # don't remove stuff we've built
provider: script
script: curl https://raw.githubusercontent.com/OpenDataServices/opendataservices-deploy/master/open-contracting-standard-deploy.sh | bash -
script: curl https://raw.githubusercontent.com/jpmckinney/opendataservices-deploy/exclude/open-contracting-standard-deploy.sh | bash -
on:
all_branches: true
141 changes: 141 additions & 0 deletions Makefile
@@ -0,0 +1,141 @@
# See https://github.com/datamade/data-making-guidelines

# See http://clarkgrubb.com/makefile-style-guide#prologue
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := all
.DELETE_ON_ERROR:
.SUFFIXES:

# See http://clarkgrubb.com/makefile-style-guide#phony-target-arg
FORCE:

# The space-separated, period-prefixed translations to build (for easier substitutions).
TRANSLATIONS=.es .fr
# The source language and translations to build.
LANGUAGES=.en $(TRANSLATIONS)

# Directory of documentation files to build with Sphinx.
DOCS_DIR=standard/docs/en
# Directory of catalog files.
CATALOGS_DIR=standard/docs/locale
# Directory in which to build documentation files.
BUILD_DIR=build
# Directory in which to build .pot files.
LOCALE_DIR=$(BUILD_DIR)/locale

# http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html
COMMA := ,
SPACE :=
SPACE +=
COMMA_SEPARATED_TRANSLATIONS=$(subst $(SPACE),$(COMMA),$(TRANSLATIONS:.%=%))

# See http://clarkgrubb.com/makefile-style-guide#phony-targets
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
rm -f $(CATALOGS_DIR)/*/LC_MESSAGES/*.mo
rm -f $(CATALOGS_DIR)/*/LC_MESSAGES/*/*.mo

### Message catalogs

$(LOCALE_DIR):
mkdir -p $(LOCALE_DIR)

.PHONY: extract_codelists
extract_codelists: $(LOCALE_DIR)
pybabel -q extract -F .babel_codelists . -o $(LOCALE_DIR)/codelists.pot

.PHONY: extract_schema
extract_schema: $(LOCALE_DIR)
pybabel -q extract -F .babel_schema . -o $(LOCALE_DIR)/schema.pot

# The codelist CSV files and JSON Schema files must be present for the `csv-table-no-translate` and `jsonschema`
# directives to succeed, but the contents of the files have no effect on the generated .pot files.
# See http://www.sphinx-doc.org/en/stable/builders.html#sphinx.builders.gettext.MessageCatalogBuilder
.PHONY: extract_markdown
extract_markdown: prebuild.en
sphinx-build -q -b gettext $(DOCS_DIR) $(LOCALE_DIR)

.PHONY: extract
extract: extract_codelists extract_schema extract_markdown clean_current_lang

### Transifex

# Builds and pushes the .pot files (`source_file` in .tx/config) to Transifex.
.PHONY: push
push: extract
tx push -s

# Also pushes the translation .po files (`file_filter` in .tx/config) to Transifex.
.PHONY: force_push_all
force_push_all: extract
tx push -s -t -l $(COMMA_SEPARATED_TRANSLATIONS) -f --no-interactive

pull.%: FORCE
tx pull -l $* -f

.PHONY: pull
pull:
tx pull -l $(COMMA_SEPARATED_TRANSLATIONS) -f

### Pre-build

# Create translated codelist CSV files, referenced by `csv-table-no-translate` directives.
translate_codelists.%: FORCE
python standard/schema/utils/translate_codelists.py standard/schema/codelists $(BUILD_DIR)/codelists $(CATALOGS_DIR) $*
python standard/schema/utils/translate_codelists.py standard/docs/en/extensions/codelists $(BUILD_DIR)/codelists $(CATALOGS_DIR) $*

# Create translated JSON Schema files in the language's build directory, referenced by `jsonschema` directives.
translate_schema.%: FORCE
python standard/schema/utils/translate_schema.py standard/schema $(BUILD_DIR) $(CATALOGS_DIR) $*

# Create a symlink for the language, so that file paths in `jsonschema` directives resolve.
# (Don't use clean_current_lang as a prerequisite, as then it won't run as a prerequisite later.)
current_lang.%: FORCE
rm -f $(BUILD_DIR)/current_lang
rm -f $(BUILD_DIR)/codelists/current_lang
ln -s $* $(BUILD_DIR)/current_lang
ln -s $* $(BUILD_DIR)/codelists/current_lang

$(LANGUAGES:.%=prebuild.%): prebuild.%: translate_codelists.% translate_schema.% current_lang.%

### Build

# Build the source documentation.
# See http://www.sphinx-doc.org/en/stable/builders.html#sphinx.builders.html.DirectoryHTMLBuilder
.PHONY: build_source
build_source: prebuild.en
sphinx-build -q -b dirhtml $(DOCS_DIR) $(BUILD_DIR)/en

# Build the translated documentation. (Same as source, but with a language configuration setting.)
$(TRANSLATIONS:.%=build.%): build.%: prebuild.%
sphinx-build -q -b dirhtml $(DOCS_DIR) $(BUILD_DIR)/$* -D language="$*"

# Deploy script complains if current_lang is present.
.PHONY: clean_current_lang
clean_current_lang:
rm $(BUILD_DIR)/current_lang
rm $(BUILD_DIR)/codelists/current_lang

# Copy the assets into the build directory.
.PHONY: assets
assets:
mkdir -p $(BUILD_DIR)
cp -r standard/assets $(BUILD_DIR)

# Compile catalogs 'codelists.po' to 'codelists.mo' and 'schema.po' to 'schema.mo', so that translate_codelists.py and
# translate_schema.py can succeed for translations.
.PHONY: compile
compile:
pybabel compile --use-fuzzy -d $(CATALOGS_DIR) -D codelists
pybabel compile --use-fuzzy -d $(CATALOGS_DIR) -D schema

.PHONY: source
source: assets | build_source clean_current_lang

$(TRANSLATIONS:.%=%): %: assets | build_source compile build.% clean_current_lang

.PHONY: all
all: assets | build_source compile $(TRANSLATIONS:.%=build.%) clean_current_lang
55 changes: 0 additions & 55 deletions build_docs.sh

This file was deleted.

87 changes: 45 additions & 42 deletions requirements.txt
@@ -1,46 +1,49 @@
Sphinx==1.5.1
# The dependency trees are determined by `pipdeptree -fl`

# Sphinx

sphinx-intl==0.9.9
# recommonmark commit pinned from master branch
-e git+https://github.com/rtfd/recommonmark.git@81d7c6f7b37981ac22571dd91a7cc9d24c3e66a1#egg=recommonmark
Babel==2.2.0
pytz==2015.7
click==6.3
setuptools==38.4.0
six==1.10.0
Sphinx==1.5.1
alabaster==0.7.7
docutils==0.12
imagesize==0.7.1
Jinja2==2.8
MarkupSafe==0.23
Pygments==2.1.1
requests==2.9.1
snowballstemmer==1.2.1
-e git+https://github.com/OpenDataServices/sphinxcontrib-jsonschema.git@e39a92f4238bf022db11e4e88ba92fdaff2b31c9#egg=sphinxcontrib-jsonschema
jsonpointer==1.10
jsonref==0.1
-e git+https://github.com/rtfd/recommonmark.git@81d7c6f7b37981ac22571dd91a7cc9d24c3e66a1#egg=recommonmark
CommonMark==0.5.4
-e git+https://github.com/open-contracting/ocds_sphinx_directives.git@199ad443e056b331ee489a59621eaeaf7a590340#egg=ocds_sphinx_directives
-e git+https://github.com/OpenDataServices/sphinxcontrib-opendataservices.git@fab0ff0167d32ec243d42f272e0e50766299c078#egg=sphinxcontrib-opendataservices
-e git+https://github.com/open-contracting/standard_theme.git@open_contracting#egg=standard_theme
-e .

# Transifex (not pinned, as not part of the build)

transifex-client

# Utils (not pinned, as not part of the build)

json-merge-patch
lxml

# Tests

flake8==3.3.0
lxml==4.1.0
pytest==2.8.7
requests-mock==0.7.0
requests==2.9.1
mccabe==0.6.1
pycodestyle==2.3.1
pyflakes==1.5.0
jsonschema==2.5.1
jsonpointer==1.10
-e git+https://github.com/open-contracting/standard_theme.git@open_contracting#egg=standard_theme
-e git+https://github.com/OpenDataServices/sphinxcontrib-jsonschema.git@09ddae1fe1aa1d8c2a56d1c937727e715074d5f8#egg=sphinxcontrib-jsonschema
-e git+https://github.com/open-contracting/ocds_sphinx_directives.git@199ad443e056b331ee489a59621eaeaf7a590340#egg=ocds_sphinx_directives
-e git+https://github.com/OpenDataServices/sphinxcontrib-opendataservices.git@23ce17656feaa237584af8822bd57ac39b498f93#egg=sphinxcontrib-opendataservices
transifex-client==0.12.5
json-merge-patch==0.1
selenium==3.5.0
.

## Dependencies of the above
alabaster==0.7.7
Babel==2.2.0
click==6.3
CommonMark==0.5.4
docutils==0.12
et-xmlfile==1.0.1
imagesize==0.7.1
jdcal==1.3
Jinja2==2.8
jsonref==0.1
Markdown==2.6.5
MarkupSafe==0.23
mccabe==0.6.1
openpyxl==2.3.5
path.py==8.1.2
polib==1.0.7
py==1.4.31
pycodestyle==2.3.1
pyflakes==1.5.0
Pygments==2.1.1
pytz==2015.7
schema==0.6.6
six==1.10.0
snowballstemmer==1.2.1
urllib3==1.22
pytest==2.8.7
py==1.4.31
selenium==3.5.0
2 changes: 0 additions & 2 deletions standard/.babel_codelists

This file was deleted.

1 change: 0 additions & 1 deletion standard/.babel_schema

This file was deleted.

5 changes: 3 additions & 2 deletions standard/docs/en/examples/merging/merge.py
@@ -1,8 +1,9 @@
import os
import json
import ocdsmerge
import os
from collections import OrderedDict

import ocdsmerge

releases = []
release_list = []
packages = []
Expand Down
4 changes: 2 additions & 2 deletions standard/docs/en/extensions/bids.md
Expand Up @@ -48,7 +48,7 @@ For example, publishers may wish to add statistics on minority or women owned bu
```eval_rst
.. csv-table-no-translate::
:header-rows: 1
:file: codelists_translated/bidStatistics.csv
:file: ../../../../build/codelists/current_lang/bidStatistics.csv
```

### Bid Details
Expand All @@ -66,7 +66,7 @@ The `bids/details` array is used to provide one or more `Bid` objects, each repr
```eval_rst
.. csv-table-no-translate::
:header-rows: 1
:file: codelists_translated/bidStatus.csv
:file: ../../../../build/codelists/current_lang/bidStatus.csv
```

### Example
Expand Down