From 70819f542c93bc8d9a59dda186533ead320958c1 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Mon, 20 Sep 2021 08:12:21 +0200 Subject: [PATCH] Add Sphinx Docs --- .github/workflows/test.yml | 42 +++++++++++++++++++++ MANIFEST.in | 2 + docs/Makefile | 20 ++++++++++ docs/environment.yml | 11 ++++++ docs/make.bat | 35 ++++++++++++++++++ docs/source/conf.py | 76 ++++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 17 +++++++++ pyproject.toml | 3 ++ readthedocs.yml | 11 ++++++ 9 files changed, 217 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/environment.yml create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst create mode 100644 readthedocs.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b30000d..a3379c2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -145,3 +145,45 @@ jobs: - name: Coverage run: | codecov + + docs: + runs-on: ubuntu-20.04 + timeout-minutes: 2 + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v2 + - name: Setup conda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + activate-environment: jupyter_releaser_documentation + environment-file: docs/environment.yml + python-version: "3.9" + auto-activate-base: false + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + - name: Cache pip + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.python-version }}- + ${{ runner.os }}-pip- + - name: Cache conda + uses: actions/cache@v2 + with: + path: ~/conda_pkgs_dir + key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ + hashFiles('docs/environment.yml') }} + - name: Build docs + run: | + set -eux + pip install . + pushd docs + make html + popd diff --git a/MANIFEST.in b/MANIFEST.in index 9761f912..7e920fc1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,6 @@ include *.md include LICENSE prune media +prune docs +exclude readthedocs.yml include jupyter_releaser/schema.json diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..d0c3cbf1 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/environment.yml b/docs/environment.yml new file mode 100644 index 00000000..eb05fd14 --- /dev/null +++ b/docs/environment.yml @@ -0,0 +1,11 @@ +name: jupyter_releaser_documentation +channels: + - conda-forge +dependencies: + - python=3.9 + - sphinx + - sphinx-copybutton + - pip + - myst-parser + - pip: + - pydata_sphinx_theme diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 00000000..061f32f9 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 00000000..58382bba --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,76 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html +# -- Path setup -------------------------------------------------------------- +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) +import os.path as osp +import shutil + +HERE = osp.abspath(osp.dirname(__file__)) + +# -- Project information ----------------------------------------------------- + +project = "Jupyter Releaser" +copyright = "2021, Project Jupyter" +author = "Project Jupyter" + +# The full version, including alpha/beta/rc tags. +release = "0.7.4" +# The short X.Y version. +version = ".".join(release.split(".")[:2]) + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = ["myst_parser"] + +myst_enable_extensions = ["html_image"] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "pydata_sphinx_theme" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add an Edit this Page button +html_theme_options = { + "use_edit_page_button": True, +} + +# Output for github to be used in links +html_context = { + "github_user": "jupyterlab", # Username + "github_repo": "jupyterlab_server", # Repo name + "github_version": "master", # Version + "doc_path": "/docs/source/", # Path in the checkout to the docs root +} + + +def setup(app): + dest = osp.join(HERE, "changelog.md") + shutil.copy(osp.join(HERE, "..", "..", "CHANGELOG.md"), dest) diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 00000000..ad447fff --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,17 @@ +Welcome to Jupyter Releaser's documentation! +============================================ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + changelog + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/pyproject.toml b/pyproject.toml index 65353399..23c68374 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,9 @@ tag_template = "v{new_version}" [[tool.tbump.file]] src = "jupyter_releaser/__init__.py" +[[tool.tbump.file]] +src = "docs/source/conf.py" + [tool.jupyter-releaser] skip = ["check-links"] diff --git a/readthedocs.yml b/readthedocs.yml new file mode 100644 index 00000000..7b6ccd8e --- /dev/null +++ b/readthedocs.yml @@ -0,0 +1,11 @@ +version: 2 +sphinx: + configuration: docs/source/conf.py +conda: + environment: docs/environment.yml +python: + version: "3.8" + install: + # install jupyter_releaser itself + - method: pip + path: .