From 402a5c0fbaf8a10110e5ec825db0dae20762f344 Mon Sep 17 00:00:00 2001 From: Sheldon Woodward Date: Sat, 14 Mar 2020 15:15:00 -0700 Subject: [PATCH] Removed pdoc and setup Sphinx. (#49) --- .github/workflows/pdoc.yml | 52 ------------------------- .github/workflows/sphinx-pr.yml | 19 +++++++++ README.md | 2 +- docs/Makefile | 20 ++++++++++ docs/make.bat | 35 +++++++++++++++++ docs/requirements.txt | 7 ++++ docs/source/conf.py | 60 +++++++++++++++++++++++++++++ docs/source/index.rst | 21 ++++++++++ docs/source/pymkv/MKVAttachment.rst | 8 ++++ docs/source/pymkv/MKVFile.rst | 8 ++++ docs/source/pymkv/MKVTrack.rst | 8 ++++ requirements.txt | 1 + setup.py | 13 +++++-- 13 files changed, 198 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/pdoc.yml create mode 100644 .github/workflows/sphinx-pr.yml create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/requirements.txt create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst create mode 100644 docs/source/pymkv/MKVAttachment.rst create mode 100644 docs/source/pymkv/MKVFile.rst create mode 100644 docs/source/pymkv/MKVTrack.rst diff --git a/.github/workflows/pdoc.yml b/.github/workflows/pdoc.yml deleted file mode 100644 index cb3061f..0000000 --- a/.github/workflows/pdoc.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build and publish pdoc documentation -on: - push: - branches: - - master -jobs: - build-n-publish: - name: Build and publish pdoc documentation - runs-on: ubuntu-18.04 - steps: - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: Install and upgrade build tool packages - run: | - pip install --upgrade setuptools twine wheel - - name: Install pdoc - run: | - pip install --upgrade pdoc - - name: Checkout master - uses: actions/checkout@v2 - with: - path: pymkv - - name: Install pymkv - run: | - pip install pymkv - - name: Build docs - run: | - pdoc --html pymkv --html-dir ../docs --overwrite - working-directory: ./pymkv - - name: Checkout gh-pages - run: | - git fetch - git checkout gh-pages - working-directory: ./pymkv - - name: Copy doc files - run: | - cp docs/pymkv/* pymkv - - name: Commit doc files - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add -A - git commit -m "Docs update." - working-directory: ./pymkv - - name: Push doc changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: gh-pages - directory: pymkv diff --git a/.github/workflows/sphinx-pr.yml b/.github/workflows/sphinx-pr.yml new file mode 100644 index 0000000..5ef0100 --- /dev/null +++ b/.github/workflows/sphinx-pr.yml @@ -0,0 +1,19 @@ +name: "Pull Request Docs Check" +on: + - pull_request + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout the PR + uses: actions/checkout@v2 + - name: Build Sphinx docs + uses: ammaraskar/sphinx-action@master + with: + docs-folder: "docs/" + - name: Upload HTML artifact + uses: actions/upload-artifact@v1 + with: + name: DocumentationHTML + path: docs/build/html/ diff --git a/README.md b/README.md index ea1b340..030152c 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,4 @@ You can also clone the repo and run the following command in the project root to $ pip install -e . ## Documentation -The documentation for pymkv can be found in the [here](https://pymkv.shel.dev/). +The documentation for pymkv can be found [here](https://pymkv.shel.dev) or in the docstrings. diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /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/make.bat b/docs/make.bat new file mode 100644 index 0000000..6247f7e --- /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.http://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/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..027f106 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,7 @@ +# project dependencies +bitmath +iso-639 + +# doc dependencies +Sphinx ~= 2.4 +sphinx_rtd_theme diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..512a777 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,60 @@ +# 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: +# http://www.sphinx-doc.org/en/master/config + +# -- 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('../..')) + + +# -- Project information ----------------------------------------------------- + +project = 'pymkv' +copyright = '2020, Sheldon Woodward' +author = 'Sheldon Woodward' + +# The full version, including alpha/beta/rc tags +release = '1.0.6' + + +# -- 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 = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.coverage', + 'sphinx.ext.napoleon' +] + +# 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 = [] + +master_doc = 'index' + + +# -- 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 = 'sphinx_rtd_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'] diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..34a5eba --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,21 @@ +Home +==== + +Welcome the pymkv documentation! + +Modules +------- + +.. toctree:: + :maxdepth: 1 + + pymkv/MKVFile + pymkv/MKVTrack + pymkv/MKVAttachment + +Indices and tables +------------------ + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/source/pymkv/MKVAttachment.rst b/docs/source/pymkv/MKVAttachment.rst new file mode 100644 index 0000000..631bc68 --- /dev/null +++ b/docs/source/pymkv/MKVAttachment.rst @@ -0,0 +1,8 @@ +MKVAttachment +------------- + +.. automodule:: pymkv.MKVAttachment + :noindex: + +.. autoclass:: pymkv.MKVAttachment + :members: diff --git a/docs/source/pymkv/MKVFile.rst b/docs/source/pymkv/MKVFile.rst new file mode 100644 index 0000000..330ef95 --- /dev/null +++ b/docs/source/pymkv/MKVFile.rst @@ -0,0 +1,8 @@ +MKVFile +------- + +.. automodule:: pymkv.MKVFile + :noindex: + +.. autoclass:: pymkv.MKVFile + :members: diff --git a/docs/source/pymkv/MKVTrack.rst b/docs/source/pymkv/MKVTrack.rst new file mode 100644 index 0000000..b80f2a3 --- /dev/null +++ b/docs/source/pymkv/MKVTrack.rst @@ -0,0 +1,8 @@ +MKVTrack +-------- + +.. automodule:: pymkv.MKVTrack + :noindex: + +.. autoclass:: pymkv.MKVTrack + :members: diff --git a/requirements.txt b/requirements.txt index a415f92..982da07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ +# project dependencies bitmath iso-639 diff --git a/setup.py b/setup.py index 5ce10f2..0a2cdd8 100644 --- a/setup.py +++ b/setup.py @@ -8,10 +8,17 @@ this_dir = abspath(dirname(__file__)) -with open(join(this_dir, 'README.rst'), encoding='utf-8') as file: +with open(join(this_dir, 'README.md'), encoding='utf-8') as file: long_description = file.read() -install_requires = [r.rstrip('\n') for r in open('requirements.txt').readlines()] +setup_requires = [ + 'setuptools_scm' +] + +install_requires = [ + 'bitmath', + 'iso-639' +] setup( @@ -38,6 +45,6 @@ keywords='wrapper', python_requires='>=3.6', use_scm_version=True, - setup_requires=['setuptools_scm'], + setup_requires=setup_requires, install_requires=install_requires, )