• Stars
    star
    480
  • Rank 91,562 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Watch a Sphinx directory and rebuild the documentation when a change is detected. Also includes a livereload enabled web server.

sphinx-autobuild

Rebuild Sphinx documentation on changes, with live-reload in the browser.

preview screenshot

Installation

sphinx-autobuild is available on PyPI. It can be installed using pip:

pip install sphinx-autobuild

Usage

To build a classical Sphinx documentation set, run:

sphinx-autobuild docs docs/_build/html

This will start a server at http://127.0.0.1:8000 and start watching for changes in the docs/ directory. When a change is detected in docs/, the documentation is rebuilt and any open browser windows are reloaded automatically. KeyboardInterrupt (ctrl+c) will stop the server.

Command line options

sphinx-autobuild accepts the same arguments as sphinx-build (these get passed to sphinx-build on each build). It also has a few additional options, which can seen by running sphinx-autobuild --help:

$ sphinx-autobuild --help
usage: sphinx-autobuild [-h] [--port PORT] [--host HOST] [--re-ignore RE_IGNORE] [--ignore IGNORE] [--no-initial] [--open-browser]
                        [--delay DELAY] [--watch DIR] [--pre-build COMMAND] [--version]
                        sourcedir outdir [filenames [filenames ...]]

positional arguments:
  sourcedir             source directory
  outdir                output directory for built documentation
  filenames             specific files to rebuild on each run (default: None)

optional arguments:
  -h, --help            show this help message and exit
  --port PORT           port to serve documentation on. 0 means find and use a free port (default: 8000)
  --host HOST           hostname to serve documentation on (default: 127.0.0.1)
  --re-ignore RE_IGNORE
                        regular expression for files to ignore, when watching for changes (default: [])
  --ignore IGNORE       glob expression for files to ignore, when watching for changes (default: [])
  --no-initial          skip the initial build (default: False)
  --open-browser        open the browser after building documentation (default: False)
  --delay DELAY         how long to wait before opening the browser (default: 5)
  --watch DIR           additional directories to watch (default: [])
  --pre-build COMMAND   additional command(s) to run prior to building the documentation (default: [])
  --version             show program's version number and exit

sphinx's arguments:
  The following arguments are forwarded as-is to Sphinx. Please look at `sphinx --help` for more information.
    -b=builder, -a, -E, -d=path, -j=N, -c=path, -C, -D=setting=value, -t=tag, -A=name=value, -n, -v, -q, -Q, -w=file, -W, -T, -N, -P

Using with Makefile

FYI: Sphinx is planning to move away from using Makefile.

To use sphinx-autobuild with the Makefile generated by Sphinx, add the following to the end of the Makefile:

livehtml:
	sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

make livehtml will now invoke sphinx-autobuild.

If you generated the Makefile with an older version of sphinx, this syntax might not work for you. Consider updating to the newer Makefile structure.

Automatically opening the browser

sphinx-autobuild can open the homepage of the generated documentation in your default browser. Passing --open-browser will enable this behaviour.

Automatically selecting a port

sphinx-autobuild asks the operating system for a free port number and use that for its server. Passing --port=0 will enable this behaviour.

Workflow suggestions

Working on a Sphinx HTML theme

When working on a Sphinx HTML theme, add the source directory of the theme as a watch directory. It is also recommended to disable Sphinx's incremental builds by passing the -a option to sphinx-autobuild.

sphinx-autobuild -a docs docs/_build/html --watch path/to/theme

This results in slower builds, but it ensures that all pages are built from the same state of the HTML theme. It also works around a known issue in Sphinx which causes significant problems during theme development.

Working on multiple projects

When working on multiple Sphinx documentation projects simultaneously, it is required to use different output directories for each project. It is also recommended to use --port=0 and --open-browser to avoid needing to manually manage ports and opening browser windows (which can get tedious quickly).

sphinx-autobuild --port=0 --open-browser pikachu/docs pikachu/docs/_build/html &
sphinx-autobuild --port=0 --open-browser magikarp/docs magickarp/docs/_build/html &

Relevant Sphinx Bugs

Sphinx does not detect changes in non-document files in incremental mode, like theme files, static files and source code used with autodoc.

At the time of writing, the only known workaround is to instruct Sphinx to rebuild the relevant pages. This can be done by disabling incremental mode (with -a) or passing relevant filenames in addition to source and output directory in the CLI.

Acknowledgements

This project stands on the shoulders of giants like Sphinx, LiveReload and python-livereload, without whom this project would not be possible.

Many thanks to everyone who has contributed code as well as participated in discussions on the issue tracker. This project is better thanks to your contribution. πŸ˜„

More Repositories

1

jupyter-book

Create beautiful, publication-quality books and documents from computational content.
Python
3,698
star
2

MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
Python
690
star
3

markdown-it-py

Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed. Now in Python!
Python
626
star
4

sphinx-book-theme

A clean book theme for scientific explanations and documentation with Sphinx
Jupyter Notebook
438
star
5

mdformat

CommonMark compliant Markdown formatter
Python
401
star
6

thebe

Turn static HTML pages into live documents with Jupyter kernels.
Jupyter Notebook
378
star
7

sphinx-tabs

Tabbed views for Sphinx
HTML
265
star
8

sphinx-copybutton

Add a "copy" button to code blocks in Sphinx
JavaScript
231
star
9

MyST-NB

Parse and execute ipynb files in Sphinx
Jupyter Notebook
207
star
10

sphinx-design

A sphinx extension for designing beautiful, screen-size responsive web components.
Python
180
star
11

mystmd

Command line tools for working with MyST Markdown.
TypeScript
161
star
12

cookiecutter-jupyter-book

Cookiecutter template for a simple jupyter book
TeX
138
star
13

jupyterlab-myst

Use MyST Markdown directly in Jupyter Lab
TypeScript
129
star
14

meta

A community dedicated to supporting tools for technical and scientific communication and interactive computing
129
star
15

sphinx-panels

A sphinx extension for creating panels in a grid layout
Python
85
star
16

rst-to-myst

Convert ReStructuredText to MyST Markdown
Python
58
star
17

github-activity

Simple markdown changelogs for GitHub repositories
Python
48
star
18

jupyter-cache

A defined interface for working with a cache of executed jupyter notebooks
Jupyter Notebook
44
star
19

sphinx-togglebutton

Show and hide content with a button in Sphinx
JavaScript
42
star
20

myst-vs-code

A syntax highlighter for the MyST Markdown format
TypeScript
35
star
21

quantecon-mini-example

A short example showing how to write a lecture series using Jupyter Book 2.0.
Python
34
star
22

sphinx-external-toc

A sphinx extension that allows the site-map to be defined in a single YAML file
Python
31
star
23

sphinx-proof

A Sphinx extension for producing proof, theorem, lemma, definition, remark, conjecture, corollary and algorithm directives.
Python
30
star
24

sphinx-jupyterbook-latex

Supporting LaTeX infrastructure for Jupyter Book
Python
28
star
25

sphinx-thebe

A Sphinx extension to convert static code into interactive code cells with Jupyter, Thebe, and Binder.
Python
28
star
26

mdit-py-plugins

Collection of core plugins for markdown-it-py
Python
28
star
27

sphinx-comments

hypothes.is interaction layer with Sphinx
Python
21
star
28

sphinx-exercise

A Sphinx extension for producing exercise and solution directives.
HTML
18
star
29

sphinx-multitoc-numbering

A Sphinx extension to support continuous numbering of sections across multiple tocs in HTML output.
Python
14
star
30

sphinx-remove-toctrees

Speed up Sphinx builds by selectively removing toctrees from some pages
Python
14
star
31

github-action-demo

A demonstration repository to build and host a book with GitHub Actions
TeX
14
star
32

quantecon-example

A demonstration of Jupyter Book functionality using QuantEcon Python programming source material.
Python
14
star
33

myst-spec

MyST is designed to create publication-quality, computational documents written entirely in Markdown.
TypeScript
13
star
34

markdown-it-docutils

A markdown-it plugin for implementing docutils style roles/directives.
TypeScript
12
star
35

mdformat-tables

An mdformat plugin for rendering tables
Python
11
star
36

mdurl

URL utilities for markdown-it (a Python port)
Python
11
star
37

jupyterlab-mystjs

Jupyterlab extension using the MySTjs parser
TypeScript
8
star
38

myst-enhancement-proposals

MyST Enhancement Proposals (MEPs)
8
star
39

myst-theme

Packages for creating MyST websites themes using React and Remix
TypeScript
8
star
40

mdformat-myst

Mdformat plugin for MyST compatibility
Python
7
star
41

cli

πŸ›‘πŸ›‘DEPRECATED, see https://github.com/ExecutableBookProject/jupyter-bookπŸ›‘πŸ›‘
Python
7
star
42

web-compile

A CLI to compile/minify SCSS & JS, and associated pre-commit hook.
Python
7
star
43

unified-myst

A repository of packages for working with MyST in the https://unifiedjs.com/ ecosystem
JavaScript
6
star
44

markdown-it-plugin-template

A template for creating a markdown-it plugin.
JavaScript
6
star
45

sphinx-ext-mystmd

Integrate existing Sphinx projects with MyST-MD
Python
5
star
46

sphinx-examples

A Sphinx extension to create examples of source markdown and the result of rendering it.
Python
5
star
47

sphinx-ext-autodoc

Auto-documentation for sphinx extension components
Python
5
star
48

sphinx-tomyst

A sphinx translator for producing myst syntax files
Python
4
star
49

mistletoe-ebp

The EPB fork of mistletoe: A fast, extensible and spec-compliant Markdown parser in pure Python.
Python
4
star
50

jupyterlab-myst-quickstart

Quickstart examples for working with MyST in Jupyter
Jupyter Notebook
4
star
51

mdformat-plugin

A template for creating an mdformat parser extension plugin
Python
4
star
52

rst2myst

Tools for converting RST files to MyST-NB files
Python
4
star
53

myst-react

A web-based UI for rendering MyST Markdown
TypeScript
4
star
54

.github

Community health files: Contributing guidelines, Code of Conduct, ...
4
star
55

markdown-it-dollarmath

A markdown-it plugin for $-delimited math
TypeScript
4
star
56

myst

Myst - Markedly Structured Text
3
star
57

python-pkg-cookiecutter

A cookiecutter for python packages, with docs and GitHub Actions CI
Python
3
star
58

mdformat-footnote

Footnote format addition for mdformat
Python
3
star
59

markdown-it-amsmath

A markdown-it plugin for amsmath LaTeX environments.
TypeScript
3
star
60

markdown-it-myst-extras

Additional plugins required for the MyST specification
TypeScript
2
star
61

myst-standard

A meta-repository to discuss and plan for the MyST standard
2
star
62

mystmd-quickstart

Repository to be used in the mystjs quickstart guide
Jupyter Notebook
2
star
63

myst-book-theme

A lightweight MyST theme designed to mimic the look-and-feel of an interactive book.
TypeScript
2
star
64

sphinx-jupyter-book-theme

An experimental Sphinx theme for Jupyter Book
HTML
2
star
65

myst-article-theme

A light-weight theme for rendering scientific articles and associated notebooks
TypeScript
2
star
66

mystmd.org

The website theme and landing content for mystmd.org
TypeScript
2
star
67

write_ups

Write ups and publications that document the project
1
star
68

sphinx-conditional-asset

A small extension for developers of Sphinx to conditionally add assets to a page.
Python
1
star
69

sphinx-yaml-config

Python
1
star