diff --git a/.gitignore b/.gitignore index e35d8850c..bf70826ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ _build +Pipfile.lock diff --git a/Pipfile b/Pipfile new file mode 100644 index 000000000..52ea333a4 --- /dev/null +++ b/Pipfile @@ -0,0 +1,14 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +sphinx = "*" +sphinx-rtd-theme = "*" +livereload = "*" + +[dev-packages] + +[requires] +python_version = "3.6" diff --git a/README.md b/README.md index c8c5fb53d..5e705d82b 100644 --- a/README.md +++ b/README.md @@ -2,28 +2,17 @@ PostgREST docs use the reStructuredText format, check this [cheatsheet](https://github.com/ralsina/rst-cheatsheet/blob/master/rst-cheatsheet.rst) to get acquainted with it. -To generate HTML version: - -1. Install Sphinx from the [sphinx website](http://www.sphinx-doc.org/en/stable/install.html) -2. Clone this repository -3. Generate HTML - ```bash - cd postgrest-docs - sphinx-build -b html -a -n . _build - - # open _build/index.html in your browser - ``` - -If you use [nix](https://nixos.org/nix/), you can just run: +You can use [pipenv](https://pipenv.readthedocs.io) to build the docs locally: +```bash + pipenv install + pipenv run python livereload_docs.py ``` + +Or if you use [nix](https://nixos.org/nix/), you can just run: + +```bash nix-shell ``` -This will build the docs and start a livereload server on `http://localhost:5500`. - ---- - -**Sphinx Installation Notes:** - -* If you're on OSX you might want to install the Python from homebrew - then a simple `pip install sphinx` does the trick. +Both of these options will build the docs and start a livereload server on `http://localhost:5500`. diff --git a/default.nix b/default.nix index 6d32f9609..c70878de8 100644 --- a/default.nix +++ b/default.nix @@ -8,7 +8,6 @@ stdenv.mkDerivation { python36Packages.sphinx_rtd_theme python36Packages.livereload ]; shellHook = '' - sphinx-build -b html -a -n . _build - python reload_docs.py && exit + python livereload_docs.py && exit ''; } diff --git a/reload_docs.py b/livereload_docs.py similarity index 68% rename from reload_docs.py rename to livereload_docs.py index 4ec06803f..9983589aa 100755 --- a/reload_docs.py +++ b/livereload_docs.py @@ -1,5 +1,8 @@ #!/usr/bin/env python from livereload import Server, shell +from subprocess import call +## Build docs at startup +call(['sphinx-build', '-b', 'html', '-a', '-n', '.', '_build']) server = Server() server.watch('*.rst', shell('sphinx-build -b html -a -n . _build')) server.watch('tutorials/*.rst', shell('sphinx-build -b html -a -n . _build'))