Skip to content
This repository was archived by the owner on Mar 18, 2022. It is now read-only.

refactoring rtd-build #6

Merged
merged 67 commits into from
Nov 20, 2015
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
55c7683
Namespace everything in readthedocs_build module
gregmuellegger Aug 10, 2015
817584b
Move integration tests into separate directory
gregmuellegger Aug 10, 2015
aef6391
Add test infrastructure with tox
gregmuellegger Aug 10, 2015
f7c1570
Add apply_fs test util to stub out project layouts
gregmuellegger Aug 10, 2015
06fb81d
Move cli module to legacy_cli since we want to supersede it
gregmuellegger Aug 10, 2015
b031ed5
Initial stub for new main method
gregmuellegger Aug 10, 2015
46ca373
Add parsing of yml config
gregmuellegger Aug 10, 2015
000a522
Add find_all logic
gregmuellegger Aug 10, 2015
a13b9dc
Add ProjectConfig and BuildConfig that load the yml files
gregmuellegger Aug 10, 2015
f3f399d
Add base config option
gregmuellegger Aug 10, 2015
68f21e0
validate on config.load
gregmuellegger Aug 10, 2015
11d6e61
Stub for build logic and SphinxBuilder
gregmuellegger Aug 10, 2015
1ebd098
Use click for new rtd-build script
gregmuellegger Aug 10, 2015
9c2533d
Make cli tests independent of the actual built
gregmuellegger Aug 13, 2015
977ce00
Validate that 'base' is a valid directory
gregmuellegger Aug 13, 2015
f7abd38
Add docstring about what is validated in BuildConfig
gregmuellegger Aug 13, 2015
8399768
Move get_project_config into testing.config
gregmuellegger Aug 13, 2015
fbb7888
Split out BaseBuilder and call setup/cleanup in build method
gregmuellegger Aug 13, 2015
671372b
Create virtualenv during build
gregmuellegger Aug 13, 2015
f7306c9
Refactor virtualenv handling into own VirtualEnv class
gregmuellegger Aug 13, 2015
08e1d64
Implement VirtualEnv.install to install packages via pip
gregmuellegger Aug 13, 2015
cbe7a9a
SphinxBuilder installs Sphinx in virtualenv
gregmuellegger Aug 13, 2015
a7a8eea
Pass env_config paramter down into BuildConfig
gregmuellegger Aug 13, 2015
339966c
Add --outdir parameter to build config as output_base
gregmuellegger Aug 13, 2015
c130536
Implement SphinxBuilder.build_html
gregmuellegger Aug 13, 2015
3cbddd2
Require name in config
gregmuellegger Aug 13, 2015
cf53108
Add integration test to check sphinx build
gregmuellegger Aug 13, 2015
955f0b9
Ignore _readthedocs_build
gregmuellegger Aug 13, 2015
90929a3
Change formatting in README.rst
gregmuellegger Aug 13, 2015
96d8f6b
Fix tox envlist
gregmuellegger Aug 13, 2015
91210a7
Add mock as dependency to tox tests
gregmuellegger Aug 13, 2015
294fbe4
Move tox env requirements into requirements/*.txt files for easier di…
gregmuellegger Aug 13, 2015
ddd3a34
Use new integration tests with tox
gregmuellegger Aug 13, 2015
6ed9161
Adjust README for new rtd-build
gregmuellegger Aug 13, 2015
49b1fc2
Require setuptools and ditch distutils support
gregmuellegger Aug 13, 2015
52e9102
Add virtualenv as requirement in setup.py
gregmuellegger Aug 13, 2015
c1d383f
Adjust todos in sphinx builder
gregmuellegger Aug 13, 2015
2ab8984
Add build_search_data method to BaseBuilder
gregmuellegger Aug 13, 2015
52b92d2
Add support for JSON format in SphinxBuilder
gregmuellegger Aug 13, 2015
d6de816
Adjust SphinxBuilder todos
gregmuellegger Aug 13, 2015
fefcfd9
Split BuildConfig.validate into multiple smaller methods
gregmuellegger Aug 13, 2015
ef28e3e
Test more options in validated build config
gregmuellegger Aug 13, 2015
9111383
Do not test for order in test_find_nested
gregmuellegger Aug 14, 2015
6a29dd9
Add .travis.yml
gregmuellegger Aug 14, 2015
15bccc1
Validate python.use_system_site_packages
gregmuellegger Aug 14, 2015
4a940b6
Accept system_site_packages flag in VirtualEnv.__init__
gregmuellegger Aug 14, 2015
82fa278
virtualenv setup respects use_system_site_packages flag
gregmuellegger Aug 14, 2015
171389e
Validate python.setup_install
gregmuellegger Aug 14, 2015
7c29f92
Add pytest-describe to nest test functions
gregmuellegger Aug 14, 2015
9fc4355
Add validation module to group config value validation
gregmuellegger Aug 14, 2015
6f318dd
Move bool validation to new validation infrastructure
gregmuellegger Aug 14, 2015
bc1a580
Add validate_choice
gregmuellegger Aug 14, 2015
85039a1
Use validation_choice for type
gregmuellegger Aug 14, 2015
bc3a090
Call validate_python in BuildConfig.validate
gregmuellegger Aug 14, 2015
1cbc793
Make sure that python defaults are always set
gregmuellegger Aug 14, 2015
96dcf09
Add validate_string
gregmuellegger Aug 14, 2015
a1da7e0
Add validate_directory
gregmuellegger Aug 14, 2015
80bcd6b
Use validate_directory in BuildConfig.validate_base
gregmuellegger Aug 14, 2015
10d6df5
Add validate_path
gregmuellegger Aug 14, 2015
a94a315
Add validate_file
gregmuellegger Aug 14, 2015
d701084
Rename python.setup_install config into python.setup_py_install
gregmuellegger Aug 14, 2015
791e8be
Add python.setup_py_path config
gregmuellegger Aug 14, 2015
88bde2c
Test VirtualEnv.python_run with absolute path to script
gregmuellegger Aug 14, 2015
84db50a
Execute setup.py install when configured
gregmuellegger Aug 14, 2015
302f14c
Add with_python_package integration test
gregmuellegger Aug 14, 2015
02777c9
Remove legacy code, like doc_builder and vcs_support package
gregmuellegger Aug 17, 2015
59c80b4
Use yaml's safe_load_all to prevent loading arbitrary code
gregmuellegger Sep 7, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
*.egg-info
_build
readthedocs_output
_readthedocs_build
autoapi
_build_rtd
/.tox/
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: python
python:
- 2.7
sudo: false
env:
- TOX_ENV=py27-unittest
- TOX_ENV=py27-integration
#- TOX_ENV=docs
#- TOX_ENV=lint
install:
- pip install tox
script:
- tox -e $TOX_ENV
notifications:
slack:
rooms:
- readthedocs:y3hjODOi7EIz1JAbD1Zb41sz#general
on_success: change
on_failure: always
76 changes: 42 additions & 34 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ This module is the main building interface to Read the Docs.
It has no explicit dependency on RTD code itself,
and can be used outside of RTD to test your builds.

.. warning:: This code is still under active development and isn't considered stable.
Please report bugs you find and contribute back if you are so inclined.
.. warning::
This code is still under active development and isn't considered
stable. Please report bugs you find and contribute back if you are so
inclined.

Install
-------
Expand All @@ -20,46 +22,52 @@ CLI Use

Running a build is simple::

rtd-build
rtd-build

This will search for a ``readthedocs.yml`` file or a ``conf.py`` file,
and build your documentation.
It will use your local Python environment.
This will search for all ``readthedocs.yml`` files below your current directory
and will build your documentation.

Using a specific ``readthedocs.yml`` file::
You can set a specific a directory where the built documentation should be
stored::

rtd-build --config=foo/rtd.yml
rtd-build --outdir=out_dir

You can set a specific output directory::
The documentation will then be placed in `out_dir/<name>/html/`. Where `<name>`
is the name configured in your `readthedocs.yml`. The default for ``--outdir``
is `_readthedocs_build`.

rtd-build --output=html_dir
Run `rtd-build --help` for more information.

Run a fully isolated build, the most similar to our Read the Docs hosting environment::
The Build
---------

rtd-build --full --output=html_dir
Here is a list of steps that `rtd-build` performs to built your documentation.
All these steps are performed for each individual section in your
``readthedocs.yml`` configs.

- it creates a new virtual environment with ``virtualenv``
- it installs the builder's dependencies into the virtualenv, for example
``Sphinx``
- it runs the build command (e.g. ``sphinx-build``) on your documentation and
puts the output into the directory specified with ``--outdir``.
- it removes the virtualenv

Library Use
-----------


An example use of this library is:

.. code-block:: python

import os

from doc_builder.loader import loading
from doc_builder.state import BuildState
import os
from readthedocs_build.build import build

docs_dir = os.getcwd()

state = BuildState(root=docs_dir)
BuilderClass = loading.get('sphinx')
builder = BuilderClass(state=state)
builder.build()

This will run the same code as RTD,
so you should be able to debug the build more easily.
build([{
'output_base': os.path.abspath('outdir'),
'name': 'docs',
'type': 'sphinx',
'base': os.path.dirname(os.path.abspath(__file__)),
}])

Development
-----------
Expand All @@ -68,19 +76,19 @@ Just run::

pip install -e .

This will install the project into your environment, and have it pick up changes as you edit them in the code.
This will install the project into your environment, and have it pick up
changes as you edit them in the code.

To run the tests::

./runtests.sh
tox

Build Process
-------------

Read the Docs creates a full environment for your build.
In your local environment,
you can choose what portions of this environment to re-create.
Read the Docs creates a full environment for your build. In your local
environment, you can choose what portions of this environment to re-create.
You can either use your existing environment with our builder code installed,
or allow our builder to create a fully isolated environment for itself.
A fully isolated environment is much closer to our production build environment for testing purposes.

or allow our builder to create a fully isolated environment for itself. A fully
isolated environment is much closer to our production build environment for
testing purposes.
File renamed without changes.
192 changes: 192 additions & 0 deletions integration_tests/minimal_project/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"

clean:
rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/minimal_project.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/minimal_project.qhc"

applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/minimal_project"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/minimal_project"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."

info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."

gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."

xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."

pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
Loading