Sign inSign up

korowai/sphinx

By korowai

•Updated over 3 years ago

Docker container with sphinx documentation generator

Image
0

3.2K

korowai/sphinx repository overview

⁠korowai/docker-sphinx

Docker container with sphinx⁠ documentation generator. The container is designed to build documentation for Korowai⁠ and Korowai Framework⁠ out of the box. It may be easily adjusted to support other projects.

⁠Image versions

⁠Features

With this container you can:

  • build documentation once and exit,
  • build documentation continuously and serve it at the same time.

The default behavior is to build continuously and serve at the same time.

⁠Quick example

Assume we have the following file hierarchy (the essential here is assumption that sphinx configuration file conf.py is found under docs/sphinx)

user@pc:$ tree .
.
`-- docs
    `-- sphinx
        |-- conf.py
        `-- index.rst
⁠Running with docker

Run it as follows

user@pc:$ docker run --rm -it -v "$(pwd):/code" -p 8000:8000 --user "`id -u`:`id -g`" korowai/sphinx
⁠Running with docker-compose

In the top level directory create docker-compose.yml containing the following

version: '3'
# ....
services:
   # ...
   sphinx:
      image: korowai/sphinx
      ports:
         - "8000:8000"
      volumes:
         - ./:/code
      user: "1000:1000"

Then run

user@pc:$ docker-compose up sphinx
⁠Results

Whatever method you chose to run the container, you shall see new directory

user@pc:$ ls -d docs/build/*
docs/build/html

The documentation is written to docs/build/html

user@pc:$ find docs -name 'index.html'
docs/build/html/index.html

As long as the container is running, the documentation is available at

⁠Customizing

Several parameters can be changed via environment variables, for example we can change build directory to build/docs/html as follows

user@pc:$ docker run --rm -it -v "$(pwd):/code" -p 8000:8000 -e SPHINX_BUILD_DIR=build/docs/html korowai/sphinx

⁠Details

⁠Volume mount points exposed
  • /code - bind top level directory of your project here.

This may be changed with the configuration variable

⁠Working directory
  • /code
⁠Files inside container
⁠In /usr/local/bin
  • scripts which may be used as container's command:
    • autobuild - builds documentation continuously (watches source directory for changes) and runs http server,
    • build - builds documentation once and exits,
  • other files
    • sphinx-defaults - initializes DEFAULT_SPHINX_xxx variables (default values),
    • sphinx-env - initializes SPHINX_xxx variables,
    • sphinx-entrypoint - provides an entry point for docker.
⁠Build arguments & environment variables

The container defines several build arguments which are copied to corresponding environment variables within the running container. Most of the arguments/variables have names starting with SPHINX_ prefix. All the scripts respect these variables, so the easiest way to adjust the container to your needs is to set environment variables (-e flag to docker⁠). KRW_CODE is an exception, it must be defined at build time.

ArgumentDefault ValueDescription
KRW_CODE/codeA predefined volume mountpoint and workdir.
SPHINX_UID1000UID of the user running commands within the container.
SPHINX_GID1000GID of the user running commands within the container.
SPHINX_VERSION2.2.0Version of sphinx to be installed (pypi).
SPHINX_AUTOBUILD_VERSION0.7.1Version of sphinx-autobuild to be installed (pypi).
SPHINX_RTD_THEME_VERSION0.4.3Version of sphinx_rtd_scheme to be installed (pypi).
SPHINX_BREATHE_VERSION4.13.1Version of breathe to be installed (pypi).
SPHINX_AUTOBUILD_HOST0.0.0.0Host address for the listening socket for http server.
SPHINX_AUTOBUILD_PORT8000Port numer (within container) for the http server.
SPHINX_AUTOBUILD_FLAGSCLI flags for running sphinx-autobuild.
SPHINX_BUILD_FLAGSCLI flags for running sphinx-build.
SPHINX_SOURCE_DIRdocs/sphinxTop-level directory conf.py for the sphinx docs.
SPHINX_BUILD_DIRdocs/build/htmlWhere to output the generated documentation.
⁠Software included

⁠LICENSE

Copyright (c) 2018 by Paweł Tomulik [email protected]⁠

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

Tag summary

Content type

Image

Digest

sha256:e15c188d8…

Size

65.9 MB

Last updated

over 3 years ago

docker pull korowai/sphinx