forked from github/pelican
Add Invoke tasks for building and serving docs
This commit is contained in:
parent
f18429f23a
commit
535df9cd9c
4 changed files with 28 additions and 5 deletions
19
tasks.py
19
tasks.py
|
|
@ -6,6 +6,7 @@ from invoke import task
|
|||
|
||||
PKG_NAME = "pelican"
|
||||
PKG_PATH = Path("pelican")
|
||||
DOCS_PORT = os.environ.get("DOCS_PORT", 8000)
|
||||
ACTIVE_VENV = os.environ.get("VIRTUAL_ENV", None)
|
||||
VENV_HOME = Path(os.environ.get("WORKON_HOME", "~/virtualenvs"))
|
||||
VENV_PATH = Path(ACTIVE_VENV) if ACTIVE_VENV else (VENV_HOME / PKG_NAME)
|
||||
|
|
@ -18,6 +19,24 @@ PRECOMMIT = (
|
|||
)
|
||||
|
||||
|
||||
@task
|
||||
def docbuild(c):
|
||||
"""Build documentation"""
|
||||
c.run(f"{VENV}/bin/sphinx-build docs docs/_build")
|
||||
|
||||
|
||||
@task(docbuild)
|
||||
def docserve(c):
|
||||
"""Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000)"""
|
||||
from livereload import Server
|
||||
|
||||
server = Server()
|
||||
server.watch("docs/conf.py", lambda: docbuild(c))
|
||||
server.watch("CONTRIBUTING.rst", lambda: docbuild(c))
|
||||
server.watch("docs/*.rst", lambda: docbuild(c))
|
||||
server.serve(port=DOCS_PORT, root="docs/_build")
|
||||
|
||||
|
||||
@task
|
||||
def tests(c):
|
||||
"""Run the test suite"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue