Skip to content

Commit

Permalink
Add some developer doc and additional tools
Browse files Browse the repository at this point in the history
Note that run_tests.sh was reporting an error, however the CI tests were passing. I added an explicit exit command to ensure the build fails if there are any failed projects.

I also added an explicit declaration of the shell to the top of run_tests.sh since I run zsh by default, and this script relies on bash specific features.

Also added the "sphinx-autobuild" tool and a "develop.sh" script that can be used to run it. It opens up a live HTML server that reloads your documentation every time it is saved, allowing you to preview it every time you save a file.
  • Loading branch information
mulby committed Jan 27, 2015
1 parent 2d58767 commit 8474b34
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 92 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ lms/lib/comment_client/python
autodeploy.properties
.ws_migrations_complete
dist

### Testing artifacts
test_root/
46 changes: 45 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,48 @@ Flow`_.
.. _GitHub Flow: https://github.com/blog/1557-github-flow-in-the-browser

All pull requests need approval from edX. For more information, contact edX at
[email protected].
[email protected].

Before submitting a pull request, it is recommend you run the test suite on
your contribution to ensure it can be compiled without errors.

To run a test compilation of a contribution, first install the prerequisites:

.. code::
pip install -r requirements.txt
Then run the tests:

.. code::
./run_tests.sh
Additionally, you can run tests for a single project:

.. code::
./run_tests.sh en_us/install_operations/
A convenience script is provided to help you develop new documentation. To use
it you must first install the optional tools, and then run the script.

.. code::
pip install -r shared/tools.txt
./develop.sh en_us/install_operations/
It will output a line of text that looks like this:

::

Serving on http://127.0.0.1:9090

You can copy this URL into a web browser to see the HTML output for your
project.

The command starts an HTTP server that renders the HTML for the project. This
HTTP server also monitors the project and detects any changes. When you save a
change to a file, the server rebuilds the HTML and refreshes your browser
automatically. In this way you can rapidly see how changes you make will be
rendered as HTML.
18 changes: 18 additions & 0 deletions develop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Allows you to preview the HTML for a project "live" in a browser view that updates everytime an ReST file is changed.

[ $# -eq 0 ] && { echo "Usage: $0 path/to/project [port]"; exit 1; }

if [ -z "$(which sphinx-autobuild)" ]
then
echo "sphinx-autobuild not found. You can install it with the command 'pip install -r shared/tools.txt'. Exiting."
exit 2
fi

project_dir=$1
port=${2:-9090}

cd $1
make html
sphinx-autobuild -b html -d build/doctrees -c source source build/html --port $port
1 change: 1 addition & 0 deletions requirements.txt
35 changes: 25 additions & 10 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/bin/bash

# Each documentation project is in a directory in the en_us folder.
# To generate docs for a project, Go to a project directory and
# run `make HTML` and `make latexpdf`.

# To test a subset of projects you can pass them in as command line
# arguments to this script. For example:
# `./run_tests.sh en_us/install_operations` would only run tests on
# the install operations project.

# The directory that this script is located in.
BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

Expand All @@ -24,16 +31,20 @@ SPHINX_ERRORS=0
# build to fail.
SPHINX_WARNINGS=0

projects=(
"en_us/course_authors"
"en_us/data"
"en_us/install_operations"
"en_us/mobile"
"en_us/olx"
"en_us/ORA2"
"en_us/release_notes"
"en_us/students"
)
projects=($@)
if [ ${#projects[@]} -eq 0 ]
then
projects=(
"en_us/course_authors"
"en_us/data"
"en_us/install_operations"
"en_us/mobile"
"en_us/olx"
"en_us/ORA2"
"en_us/release_notes"
"en_us/students"
)
fi

for project in "${projects[@]}"; do
cd $BASE_DIR/$project
Expand Down Expand Up @@ -88,11 +99,15 @@ echo TOTAL SPHINX ERRORS: $SPHINX_ERRORS
echo TOTAL SPHINX WARNINGS: $SPHINX_WARNINGS
echo OTHER BUILD ERRORS: $BUILD_ERRORS

EXIT_STATUS=0
if [ ${#FAILED_BUILDS[@]} -gt 0 ]; then
echo "There were errors while building the following projects:"
for project in "${FAILED_BUILDS[@]}"; do
echo $project
done
EXIT_STATUS=1
else
echo "All builds passed."
fi

exit $EXIT_STATUS
81 changes: 0 additions & 81 deletions shared/requirements.txt

This file was deleted.

1 change: 1 addition & 0 deletions shared/tools.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinx-autobuild==0.4.0

0 comments on commit 8474b34

Please sign in to comment.