├── requirements.txt ├── docs ├── authors.rst ├── history.rst ├── readme.rst ├── contributing.rst ├── requirements.txt ├── usage.rst ├── modules.rst ├── index.rst ├── Makefile ├── make.bat ├── installation.rst └── conf.py ├── tests ├── __init__.py └── test_param_docs.py ├── HISTORY.rst ├── param_docs ├── __init__.py ├── test_formatter.py ├── cli.py ├── controller.py └── paramdoc.py ├── requirements_dev.txt ├── AUTHORS.rst ├── MANIFEST.in ├── .travis.yml ├── tox.ini ├── .editorconfig ├── .github └── ISSUE_TEMPLATE.md ├── setup.cfg ├── readthedocs.yml ├── LICENSE ├── README.rst ├── setup.py ├── .gitignore ├── Makefile └── CONTRIBUTING.rst /requirements.txt: -------------------------------------------------------------------------------- 1 | param 2 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx==3.2.1 2 | param 3 | numpydoc 4 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Unit test package for param_docs.""" 2 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | History 3 | ======= 4 | 5 | 0.1.0 (2020-09-10) 6 | ------------------ 7 | 8 | * First release on PyPI. 9 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Usage 3 | ===== 4 | 5 | **bold** *italics* ``verbatim`` 6 | 7 | To use param_docs in a project:: 8 | 9 | import param_docs 10 | -------------------------------------------------------------------------------- /param_docs/__init__.py: -------------------------------------------------------------------------------- 1 | """Top-level package for param_docs.""" 2 | 3 | __author__ = """Jochem Smit""" 4 | __email__ = 'jhsmit@gmail.com' 5 | __version__ = '0.1.0' 6 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | pip==19.2.3 2 | bump2version==0.5.11 3 | wheel==0.33.6 4 | watchdog==0.9.0 5 | flake8==3.7.8 6 | tox==3.14.0 7 | coverage==4.5.4 8 | Sphinx==1.8.5 9 | twine==1.14.0 10 | Click==7.0 11 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Jochem Smit 9 | 10 | Contributors 11 | ------------ 12 | 13 | None yet. Why not be the first? 14 | -------------------------------------------------------------------------------- /docs/modules.rst: -------------------------------------------------------------------------------- 1 | .. _apidocs: 2 | 3 | Param Docs 4 | ========== 5 | 6 | This page contains auto-generated docs for the GUI. 7 | 8 | 9 | Controllers 10 | ----------- 11 | 12 | .. automodule:: param_docs.controller 13 | :members: 14 | 15 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | 7 | recursive-include tests * 8 | recursive-exclude * __pycache__ 9 | recursive-exclude * *.py[co] 10 | 11 | recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Config file for automatic testing at travis-ci.com 2 | 3 | language: python 4 | python: 5 | - 3.8 6 | - 3.7 7 | - 3.6 8 | - 3.5 9 | 10 | # Command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors 11 | install: pip install -U tox-travis 12 | 13 | # Command to run tests, e.g. python setup.py test 14 | script: tox 15 | 16 | 17 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py35, py36, py37, py38, flake8 3 | 4 | [travis] 5 | python = 6 | 3.8: py38 7 | 3.7: py37 8 | 3.6: py36 9 | 3.5: py35 10 | 11 | [testenv:flake8] 12 | basepython = python 13 | deps = flake8 14 | commands = flake8 param_docs tests 15 | 16 | [testenv] 17 | setenv = 18 | PYTHONPATH = {toxinidir} 19 | 20 | commands = python setup.py test 21 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | * param_docs version: 2 | * Python version: 3 | * Operating System: 4 | 5 | ### Description 6 | 7 | Describe what you were trying to get done. 8 | Tell us what happened, what went wrong, and what you expected to happen. 9 | 10 | ### What I Did 11 | 12 | ``` 13 | Paste the command(s) you ran and the output. 14 | If there was a crash, please include the traceback here. 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to param_docs's documentation! 2 | ====================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :caption: Contents: 7 | 8 | readme 9 | installation 10 | usage 11 | modules 12 | contributing 13 | authors 14 | history 15 | 16 | Indices and tables 17 | ================== 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /param_docs/test_formatter.py: -------------------------------------------------------------------------------- 1 | from param_docs.paramdoc import param_format_basic 2 | from param_docs.controller import FruitStallController 3 | import param 4 | 5 | tc = FruitStallController() 6 | 7 | print(isinstance(FruitStallController, param.parameterized.ParameterizedMetaclass)) 8 | lines = [] 9 | 10 | param_format_basic('app', 'class', 'name', FruitStallController, 'options', lines) 11 | 12 | print(lines) -------------------------------------------------------------------------------- /param_docs/cli.py: -------------------------------------------------------------------------------- 1 | """Console script for param_docs.""" 2 | import sys 3 | import click 4 | 5 | 6 | @click.command() 7 | def main(args=None): 8 | """Console script for param_docs.""" 9 | click.echo("Replace this message by putting your code into " 10 | "param_docs.cli.main") 11 | click.echo("See click documentation at https://click.palletsprojects.com/") 12 | return 0 13 | 14 | 15 | if __name__ == "__main__": 16 | sys.exit(main()) # pragma: no cover 17 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.1.0 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | search = version='{current_version}' 8 | replace = version='{new_version}' 9 | 10 | [bumpversion:file:param_docs/__init__.py] 11 | search = __version__ = '{current_version}' 12 | replace = __version__ = '{new_version}' 13 | 14 | [bdist_wheel] 15 | universal = 1 16 | 17 | [flake8] 18 | exclude = docs 19 | 20 | [aliases] 21 | # Define setup.py command aliases here 22 | 23 | -------------------------------------------------------------------------------- /readthedocs.yml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Build documentation in the docs/ directory with Sphinx 9 | sphinx: 10 | configuration: docs/conf.py 11 | 12 | # Build documentation with MkDocs 13 | #mkdocs: 14 | # configuration: mkdocs.yml 15 | 16 | # Optionally build your docs in additional formats such as PDF 17 | formats: 18 | - pdf 19 | 20 | # Optionally set the version of Python and requirements required to build your docs 21 | python: 22 | version: 3.7 23 | install: 24 | - requirements: docs/requirements.txt 25 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = python -msphinx 7 | SPHINXPROJ = param_docs 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=python -msphinx 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=param_docs 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The Sphinx module was not found. Make sure you have Sphinx installed, 20 | echo.then set the SPHINXBUILD environment variable to point to the full 21 | echo.path of the 'sphinx-build' executable. Alternatively you may add the 22 | echo.Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /tests/test_param_docs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Tests for `param_docs` package.""" 4 | 5 | 6 | import unittest 7 | from click.testing import CliRunner 8 | 9 | from param_docs import paramdoc 10 | from param_docs import cli 11 | 12 | 13 | class TestParam_docs(unittest.TestCase): 14 | """Tests for `param_docs` package.""" 15 | 16 | def setUp(self): 17 | """Set up test fixtures, if any.""" 18 | 19 | def tearDown(self): 20 | """Tear down test fixtures, if any.""" 21 | 22 | def test_000_something(self): 23 | """Test something.""" 24 | 25 | def test_command_line_interface(self): 26 | """Test the CLI.""" 27 | runner = CliRunner() 28 | result = runner.invoke(cli.main) 29 | assert result.exit_code == 0 30 | assert 'param_docs.cli.main' in result.output 31 | help_result = runner.invoke(cli.main, ['--help']) 32 | assert help_result.exit_code == 0 33 | assert '--help Show this message and exit.' in help_result.output 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020, Jochem Smit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | 8 | Stable release 9 | -------------- 10 | 11 | To install param_docs, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install param_docs 16 | 17 | This is the preferred method to install param_docs, as it will always install the most recent stable release. 18 | 19 | If you don't have `pip`_ installed, this `Python installation guide`_ can guide 20 | you through the process. 21 | 22 | .. _pip: https://pip.pypa.io 23 | .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ 24 | 25 | 26 | From sources 27 | ------------ 28 | 29 | The sources for param_docs can be downloaded from the `Github repo`_. 30 | 31 | You can either clone the public repository: 32 | 33 | .. code-block:: console 34 | 35 | $ git clone git://github.com/Jhsmit/param_docs 36 | 37 | Or download the `tarball`_: 38 | 39 | .. code-block:: console 40 | 41 | $ curl -OJL https://github.com/Jhsmit/param_docs/tarball/master 42 | 43 | Once you have a copy of the source, you can install it with: 44 | 45 | .. code-block:: console 46 | 47 | $ python setup.py install 48 | 49 | 50 | .. _Github repo: https://github.com/Jhsmit/param_docs 51 | .. _tarball: https://github.com/Jhsmit/param_docs/tarball/master 52 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | param_docs 3 | ========== 4 | 5 | 6 | .. image:: https://img.shields.io/pypi/v/param_docs.svg 7 | :target: https://pypi.python.org/pypi/param_doc 8 | 9 | .. image:: https://img.shields.io/travis/Jhsmit/param_docs.svg 10 | :target: https://travis-ci.com/Jhsmit/param_docs 11 | 12 | .. image:: https://readthedocs.org/projects/param-doc/badge/?version=latest 13 | :target: https://param-doc.readthedocs.io/en/latest/?badge=latest 14 | :alt: Documentation Status 15 | 16 | 17 | 18 | 19 | Test package for generating docs from param.Parameterized classes 20 | 21 | 22 | * Free software: MIT license 23 | * Documentation: https://param-doc.readthedocs.io. 24 | 25 | 26 | Features 27 | -------- 28 | 29 | This an example project of how to customize sphinx autodoc generation from param.Parameterized classes. The aim is to generate docs which are informative for users of the web application, where components are by ``param.Parameterized subclass`` 'controllers'. 30 | Numpydoc style docstrings are assumed for normal (non ``Parameterized``) classes, which is supressed for ``Parameterized`` classes. 31 | 32 | 33 | 34 | 35 | Credits 36 | ------- 37 | The code for formatting docstrings is based on Pyviz' nbsite paramdoc_ 38 | 39 | This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. 40 | 41 | .. _paramdoc: https://github.com/pyviz-dev/nbsite/blob/master/nbsite/paramdoc.py 42 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 43 | .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage 44 | 45 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """The setup script.""" 4 | 5 | from setuptools import setup, find_packages 6 | 7 | with open('README.rst') as readme_file: 8 | readme = readme_file.read() 9 | 10 | with open('HISTORY.rst') as history_file: 11 | history = history_file.read() 12 | 13 | requirements = ['Click>=7.0', ] 14 | 15 | setup_requirements = [ ] 16 | 17 | test_requirements = [ ] 18 | 19 | setup( 20 | author="Jochem Smit", 21 | author_email='jhsmit@gmail.com', 22 | python_requires='>=3.5', 23 | classifiers=[ 24 | 'Development Status :: 2 - Pre-Alpha', 25 | 'Intended Audience :: Developers', 26 | 'License :: OSI Approved :: MIT License', 27 | 'Natural Language :: English', 28 | 'Programming Language :: Python :: 3', 29 | 'Programming Language :: Python :: 3.5', 30 | 'Programming Language :: Python :: 3.6', 31 | 'Programming Language :: Python :: 3.7', 32 | 'Programming Language :: Python :: 3.8', 33 | ], 34 | description="Test package for generating docs from param.Parameterized classes", 35 | entry_points={ 36 | 'console_scripts': [ 37 | 'param_docs=param_docs.cli:main', 38 | ], 39 | }, 40 | install_requires=requirements, 41 | license="MIT license", 42 | long_description=readme + '\n\n' + history, 43 | include_package_data=True, 44 | keywords='param_docs', 45 | name='param_docs', 46 | packages=find_packages(include=['param_docs', 'param_docs.*']), 47 | setup_requires=setup_requirements, 48 | test_suite='tests', 49 | tests_require=test_requirements, 50 | url='https://github.com/Jhsmit/param_docs', 51 | version='0.1.0', 52 | zip_safe=False, 53 | ) 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | 58 | # Flask stuff: 59 | instance/ 60 | .webassets-cache 61 | 62 | # Scrapy stuff: 63 | .scrapy 64 | 65 | # Sphinx documentation 66 | docs/_build/ 67 | 68 | # PyBuilder 69 | target/ 70 | 71 | # Jupyter Notebook 72 | .ipynb_checkpoints 73 | 74 | # pyenv 75 | .python-version 76 | 77 | # celery beat schedule file 78 | celerybeat-schedule 79 | 80 | # SageMath parsed files 81 | *.sage.py 82 | 83 | # dotenv 84 | .env 85 | 86 | # virtualenv 87 | .venv 88 | venv/ 89 | ENV/ 90 | 91 | # Spyder project settings 92 | .spyderproject 93 | .spyproject 94 | 95 | # Rope project settings 96 | .ropeproject 97 | 98 | # mkdocs documentation 99 | /site 100 | 101 | # mypy 102 | .mypy_cache/ 103 | 104 | # IDE settings 105 | .vscode/ 106 | .idea/ -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean clean-test clean-pyc clean-build docs help 2 | .DEFAULT_GOAL := help 3 | 4 | define BROWSER_PYSCRIPT 5 | import os, webbrowser, sys 6 | 7 | from urllib.request import pathname2url 8 | 9 | webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) 10 | endef 11 | export BROWSER_PYSCRIPT 12 | 13 | define PRINT_HELP_PYSCRIPT 14 | import re, sys 15 | 16 | for line in sys.stdin: 17 | match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) 18 | if match: 19 | target, help = match.groups() 20 | print("%-20s %s" % (target, help)) 21 | endef 22 | export PRINT_HELP_PYSCRIPT 23 | 24 | BROWSER := python -c "$$BROWSER_PYSCRIPT" 25 | 26 | help: 27 | @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) 28 | 29 | clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts 30 | 31 | clean-build: ## remove build artifacts 32 | rm -fr build/ 33 | rm -fr dist/ 34 | rm -fr .eggs/ 35 | find . -name '*.egg-info' -exec rm -fr {} + 36 | find . -name '*.egg' -exec rm -f {} + 37 | 38 | clean-pyc: ## remove Python file artifacts 39 | find . -name '*.pyc' -exec rm -f {} + 40 | find . -name '*.pyo' -exec rm -f {} + 41 | find . -name '*~' -exec rm -f {} + 42 | find . -name '__pycache__' -exec rm -fr {} + 43 | 44 | clean-test: ## remove test and coverage artifacts 45 | rm -fr .tox/ 46 | rm -f .coverage 47 | rm -fr htmlcov/ 48 | rm -fr .pytest_cache 49 | 50 | lint: ## check style with flake8 51 | flake8 param_docs tests 52 | 53 | test: ## run tests quickly with the default Python 54 | python setup.py test 55 | 56 | test-all: ## run tests on every Python version with tox 57 | tox 58 | 59 | coverage: ## check code coverage quickly with the default Python 60 | coverage run --source param_docs setup.py test 61 | coverage report -m 62 | coverage html 63 | $(BROWSER) htmlcov/index.html 64 | 65 | docs: ## generate Sphinx HTML documentation, including API docs 66 | rm -f docs/param_docs.rst 67 | rm -f docs/modules.rst 68 | sphinx-apidoc -o docs/ param_docs 69 | $(MAKE) -C docs clean 70 | $(MAKE) -C docs html 71 | $(BROWSER) docs/_build/html/index.html 72 | 73 | servedocs: docs ## compile the docs watching for changes 74 | watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . 75 | 76 | release: dist ## package and upload a release 77 | twine upload dist/* 78 | 79 | dist: clean ## builds source and wheel package 80 | python setup.py sdist 81 | python setup.py bdist_wheel 82 | ls -l dist 83 | 84 | install: clean ## install the package to the active Python's site-packages 85 | python setup.py install 86 | -------------------------------------------------------------------------------- /param_docs/controller.py: -------------------------------------------------------------------------------- 1 | import param 2 | 3 | 4 | class FruitStallController(param.Parameterized): 5 | """ 6 | This controller lets the user choose a type of fruit, set the amount and then buy some. 7 | The docstring has two lines. Which is ignored. Lets try some whitespace. 8 | 9 | This is the next line after the whitespace. 10 | """ 11 | title = 'Fruit Stall' 12 | random_attribute = 10 # not shown in GUI 13 | hidden_param = param.Boolean(precedence=-1, 14 | doc='This parameter is documented but due to low precedence not shown in documentation.') 15 | fruit = param.Selector(default='apple', objects=['apple', 'pear', 'banana'], 16 | doc='Select type of fruit to buy.') 17 | quantity = param.Integer(5, bounds=(0, None), doc='Number of selected fruit to buy.') 18 | price = param.Number(0., constant=True, bounds=(0, None), doc='Price of the fruit per piece.') 19 | button = param.Action(lambda x: print('You bought fruit'), 20 | doc='Press this button to buy some fruit!', label='Make Purchase') 21 | 22 | def __init__(self, **params): 23 | super(FruitStallController, self).__init__(**params) 24 | 25 | @param.depends('fruit', watch=True) 26 | def _update_price(self): 27 | price_list = {'apple': 1.30, 'pear': 1.55, 'banana': 2.00} 28 | self.price = price_list[self.fruit] 29 | 30 | 31 | class SuperMarketController(FruitStallController): 32 | """ 33 | This controller extends the Fruit Stall into a Supermarket, also offering users a selection of milk and cheeses. 34 | """ 35 | title = 'Supermarket' 36 | 37 | milk = param.Selector(default='semi-skimmed', objects=['full-fat', 'semi-skimmed', 'skimmed'], 38 | doc='Select fat content for the milk.') 39 | cheese = param.Selector(default='Jong Belegen', objects=['Jong Belegen', 'Brie', 'Reblouchon'], 40 | doc='Jong Belegen is highly recommended.') 41 | 42 | def __init__(self, **params): 43 | super(FruitStallController, self).__init__(**params) 44 | 45 | 46 | class NormalClass(object): 47 | """ 48 | This is a normal numpydoc style docstring 49 | 50 | Parameters 51 | ---------- 52 | arg1 : :obj:`float` 53 | Argument 1 54 | arg2 : :obj:`float` 55 | Argument 2 56 | 57 | Attributes 58 | ---------- 59 | 60 | arg : :obj:`float` 61 | Argument 62 | 63 | """ 64 | 65 | def __init__(self, arg1, arg2): 66 | self.arg = arg1 + arg2 67 | 68 | def do_something(self): 69 | """ 70 | This function does a thing. 71 | 72 | Returns 73 | ------- 74 | ans : :obj:`float` 75 | Returns the double of the `arg` attribute. 76 | """ 77 | ans = self.arg*2 78 | return ans 79 | 80 | 81 | if __name__ == "__main__": 82 | 83 | fruit_stall = FruitStallController() 84 | print(fruit_stall.__doc__) #prints normal param docstring 85 | 86 | supermarket = SuperMarketController() 87 | print(supermarket.__doc__) 88 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Contributing 5 | ============ 6 | 7 | Contributions are welcome, and they are greatly appreciated! Every little bit 8 | helps, and credit will always be given. 9 | 10 | You can contribute in many ways: 11 | 12 | Types of Contributions 13 | ---------------------- 14 | 15 | Report Bugs 16 | ~~~~~~~~~~~ 17 | 18 | Report bugs at https://github.com/Jhsmit/param_docs/issues. 19 | 20 | If you are reporting a bug, please include: 21 | 22 | * Your operating system name and version. 23 | * Any details about your local setup that might be helpful in troubleshooting. 24 | * Detailed steps to reproduce the bug. 25 | 26 | Fix Bugs 27 | ~~~~~~~~ 28 | 29 | Look through the GitHub issues for bugs. Anything tagged with "bug" and "help 30 | wanted" is open to whoever wants to implement it. 31 | 32 | Implement Features 33 | ~~~~~~~~~~~~~~~~~~ 34 | 35 | Look through the GitHub issues for features. Anything tagged with "enhancement" 36 | and "help wanted" is open to whoever wants to implement it. 37 | 38 | Write Documentation 39 | ~~~~~~~~~~~~~~~~~~~ 40 | 41 | param_docs could always use more documentation, whether as part of the 42 | official param_docs docs, in docstrings, or even on the web in blog posts, 43 | articles, and such. 44 | 45 | Submit Feedback 46 | ~~~~~~~~~~~~~~~ 47 | 48 | The best way to send feedback is to file an issue at https://github.com/Jhsmit/param_docs/issues. 49 | 50 | If you are proposing a feature: 51 | 52 | * Explain in detail how it would work. 53 | * Keep the scope as narrow as possible, to make it easier to implement. 54 | * Remember that this is a volunteer-driven project, and that contributions 55 | are welcome :) 56 | 57 | Get Started! 58 | ------------ 59 | 60 | Ready to contribute? Here's how to set up `param_docs` for local development. 61 | 62 | 1. Fork the `param_docs` repo on GitHub. 63 | 2. Clone your fork locally:: 64 | 65 | $ git clone git@github.com:your_name_here/param_docs.git 66 | 67 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 68 | 69 | $ mkvirtualenv param_docs 70 | $ cd param_docs/ 71 | $ python setup.py develop 72 | 73 | 4. Create a branch for local development:: 74 | 75 | $ git checkout -b name-of-your-bugfix-or-feature 76 | 77 | Now you can make your changes locally. 78 | 79 | 5. When you're done making changes, check that your changes pass flake8 and the 80 | tests, including testing other Python versions with tox:: 81 | 82 | $ flake8 param_docs tests 83 | $ python setup.py test or pytest 84 | $ tox 85 | 86 | To get flake8 and tox, just pip install them into your virtualenv. 87 | 88 | 6. Commit your changes and push your branch to GitHub:: 89 | 90 | $ git add . 91 | $ git commit -m "Your detailed description of your changes." 92 | $ git push origin name-of-your-bugfix-or-feature 93 | 94 | 7. Submit a pull request through the GitHub website. 95 | 96 | Pull Request Guidelines 97 | ----------------------- 98 | 99 | Before you submit a pull request, check that it meets these guidelines: 100 | 101 | 1. The pull request should include tests. 102 | 2. If the pull request adds functionality, the docs should be updated. Put 103 | your new functionality into a function with a docstring, and add the 104 | feature to the list in README.rst. 105 | 3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check 106 | https://travis-ci.com/Jhsmit/param_docs/pull_requests 107 | and make sure that the tests pass for all supported Python versions. 108 | 109 | Tips 110 | ---- 111 | 112 | To run a subset of tests:: 113 | 114 | 115 | $ python -m unittest tests.test_param_docs 116 | 117 | Deploying 118 | --------- 119 | 120 | A reminder for the maintainers on how to deploy. 121 | Make sure all your changes are committed (including an entry in HISTORY.rst). 122 | Then run:: 123 | 124 | $ bump2version patch # possible: major / minor / patch 125 | $ git push 126 | $ git push --tags 127 | 128 | Travis will then deploy to PyPI if tests pass. 129 | -------------------------------------------------------------------------------- /param_docs/paramdoc.py: -------------------------------------------------------------------------------- 1 | """Main module.""" 2 | import inspect 3 | from functools import partial 4 | 5 | try: 6 | from numpydoc.numpydoc import DEDUPLICATION_TAG 7 | except ImportError: 8 | DEDUPLICATION_TAG = '' 9 | 10 | import param 11 | 12 | from param.parameterized import label_formatter 13 | 14 | param.parameterized.docstring_signature = False 15 | param.parameterized.docstring_describe_params = False 16 | 17 | # Parameter attributes which are never shown 18 | IGNORED_ATTRS = [ 19 | 'precedence', 'check_on_set', 'instantiate', 'pickle_default_value', 20 | 'watchers', 'compute_default_fn', 'doc', 'owner', 'per_instance', 21 | 'constant', 'is_instance', 'name', 'allow_None', 'time_fn', 22 | 'time_dependent', 'label', 'inclusive_bounds' 23 | ] 24 | 25 | # Default parameter attribute values (value not shown if it matches defaults) 26 | DEFAULT_VALUES = {'allow_None': False, 'readonly': False} 27 | 28 | 29 | def print_lines(app, what, name, obj, options, lines): 30 | print(lines) 31 | 32 | 33 | def param_format_basic(app, what, name, obj, options, lines): 34 | # if what == 'module': 35 | # lines = ["start"] 36 | if what == 'class' and isinstance(obj, param.parameterized.ParameterizedMetaclass): 37 | # lines += ['..', DEDUPLICATION_TAG] # Prevent numpydoc from mangling the docstring 38 | lines += ['Other Parameters', '----------------'] 39 | 40 | try: 41 | lines.insert(0, '') 42 | lines.insert(0, f'**{obj.title}**') 43 | except AttributeError: 44 | pass 45 | 46 | parameters = ['name'] 47 | mro = obj.mro()[::-1] 48 | inherited = [] 49 | for cls in mro[:-1]: 50 | if not issubclass(cls, param.Parameterized) or cls is param.Parameterized: 51 | continue 52 | cls_params = [p for p in cls.param if p not in parameters and 53 | cls.param[p] == obj.param[p]] 54 | if not cls_params: 55 | continue 56 | parameters += cls_params 57 | cname = cls.__name__ 58 | module = cls.__module__ 59 | params = ', '.join([f'**{p}**' for p in cls_params]) 60 | inherited.extend(['', ' :class:`{module}.{name}`: {params}'.format( 61 | name=cname, module=module, params=params) 62 | ]) 63 | 64 | 65 | params = [p for p in obj.param if p not in parameters] 66 | for child in params: 67 | pobj = obj.param[child] 68 | if child in ["print_level", "name"]: 69 | continue 70 | if pobj.precedence and pobj.precedence < 0: 71 | continue 72 | 73 | label = label_formatter(pobj.name) 74 | doc = pobj.doc or "" 75 | members = inspect.getmembers(pobj) 76 | params_str = "" 77 | for m in members: 78 | # This formats default='apple', objects=['apple', 'pear', 'banana'] etc 79 | if (m[0][0] != "_" and m[0] not in IGNORED_ATTRS and 80 | not inspect.ismethod(m[1]) and not inspect.isfunction(m[1]) and 81 | m[1] is not None and # DEFAULT_VALUES.get(m[0]) != m[1] and 82 | (m[0] != 'label' or pobj.label != label)): 83 | subtitutions = {'objects': 'options'} 84 | key = subtitutions.get(m[0], m[0]) 85 | 86 | params_str += "%s=%s, " % (key, repr(m[1])) 87 | params_str = params_str[:-2] 88 | ptype = pobj.__class__.__name__ 89 | 90 | display_name = pobj.label or ' '.join(s.capitalize() for s in child.split('_')) 91 | if params_str.lstrip(): 92 | lines.extend([f"{display_name}: {ptype} ({params_str})"]) 93 | else: 94 | lines.extend([f"{display_name}: {ptype}"]) 95 | lines.extend([" " + doc]) 96 | lines.append('') 97 | 98 | 99 | 100 | if inherited: 101 | lines.extend(["Additional GUI elements on: "]+inherited) 102 | 103 | 104 | def param_skip(app, what, name, obj, skip, options): 105 | if what == 'class' and not skip: 106 | return ( 107 | getattr(obj, '__qualname__', '').startswith('Parameters.deprecate') or 108 | (isinstance(obj, partial) and obj.args and isinstance(obj.args[0], param.Parameterized)) or 109 | (getattr(obj, '__qualname__', '').startswith('Parameterized.') and 110 | getattr(obj, '__class__', str).__name__ == 'function') 111 | ) 112 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # param_docs documentation build configuration file, created by 4 | # sphinx-quickstart on Fri Jun 9 13:47:02 2017. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | # If extensions (or modules to document with autodoc) are in another 16 | # directory, add these directories to sys.path here. If the directory is 17 | # relative to the documentation root, use os.path.abspath to make it 18 | # absolute, like shown here. 19 | # 20 | import os 21 | import sys 22 | sys.path.insert(0, os.path.abspath('..')) 23 | 24 | import param_docs 25 | from param_docs.paramdoc import param_format_basic, print_lines 26 | import param 27 | import numpydoc 28 | 29 | 30 | 31 | # -- General configuration --------------------------------------------- 32 | 33 | # If your documentation needs a minimal Sphinx version, state it here. 34 | # 35 | # needs_sphinx = '1.0' 36 | 37 | # def process_signature(app, what, name, obj, options, signature, return_annotation): 38 | # 39 | # return 'modified_signature', 'modified_return_annotation' 40 | # # will be rendered to method(modified_signature) -> modified_return_annotation 41 | # 42 | # def process_docstring(app, what, name, obj, options, lines): 43 | # print(lines) 44 | # if what == 'class' and isinstance(obj, param.parameterized.ParameterizedMetaclass): 45 | # #del lines[:] 46 | # lines += ['..', DEDUPLICATION_TAG] 47 | 48 | # latex_engine = 'xelatex' 49 | autodoc_member_order = 'bysource' 50 | 51 | 52 | def setup(app): 53 | app.connect("autodoc-process-docstring", param_format_basic, priority=-100) 54 | #app.connect("autodoc-process-docstring", print_lines) 55 | 56 | 57 | # Add any Sphinx extension module names here, as strings. They can be 58 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 59 | extensions = [ 60 | 'sphinx.ext.autodoc', 61 | 'sphinx.ext.intersphinx', 62 | 'sphinx.ext.mathjax', 63 | 'sphinx.ext.viewcode', 64 | 'numpydoc', 65 | # 'sphinxcontrib.bibtex' 66 | ] 67 | 68 | # Add any paths that contain templates here, relative to this directory. 69 | templates_path = ['_templates'] 70 | 71 | # The suffix(es) of source filenames. 72 | # You can specify multiple suffix as a list of string: 73 | # 74 | # source_suffix = ['.rst', '.md'] 75 | source_suffix = '.rst' 76 | 77 | # The master toctree document. 78 | master_doc = 'index' 79 | 80 | # General information about the project. 81 | project = 'param_docs' 82 | copyright = "2020, Jochem Smit" 83 | author = "Jochem Smit" 84 | 85 | # The version info for the project you're documenting, acts as replacement 86 | # for |version| and |release|, also used in various other places throughout 87 | # the built documents. 88 | # 89 | # The short X.Y version. 90 | version = param_docs.__version__ 91 | # The full version, including alpha/beta/rc tags. 92 | release = param_docs.__version__ 93 | 94 | # The language for content autogenerated by Sphinx. Refer to documentation 95 | # for a list of supported languages. 96 | # 97 | # This is also used if you do content translation via gettext catalogs. 98 | # Usually you set "language" from the command line for these cases. 99 | language = None 100 | 101 | # List of patterns, relative to source directory, that match files and 102 | # directories to ignore when looking for source files. 103 | # This patterns also effect to html_static_path and html_extra_path 104 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 105 | 106 | # The name of the Pygments (syntax highlighting) style to use. 107 | pygments_style = 'sphinx' 108 | 109 | # If true, `todo` and `todoList` produce output, else they produce nothing. 110 | todo_include_todos = False 111 | 112 | 113 | # -- Options for HTML output ------------------------------------------- 114 | 115 | # The theme to use for HTML and HTML Help pages. See the documentation for 116 | # a list of builtin themes. 117 | # 118 | html_theme = 'sphinx_rtd_theme' 119 | 120 | # Theme options are theme-specific and customize the look and feel of a 121 | # theme further. For a list of options available for each theme, see the 122 | # documentation. 123 | # 124 | # html_theme_options = {} 125 | 126 | # Add any paths that contain custom static files (such as style sheets) here, 127 | # relative to this directory. They are copied after the builtin static files, 128 | # so a file named "default.css" will overwrite the builtin "default.css". 129 | html_static_path = ['_static'] 130 | 131 | 132 | # -- Options for HTMLHelp output --------------------------------------- 133 | 134 | # Output file base name for HTML help builder. 135 | htmlhelp_basename = 'param_docsdoc' 136 | 137 | 138 | # -- Options for LaTeX output ------------------------------------------ 139 | 140 | latex_elements = { 141 | # The paper size ('letterpaper' or 'a4paper'). 142 | # 143 | # 'papersize': 'letterpaper', 144 | 145 | # The font size ('10pt', '11pt' or '12pt'). 146 | # 147 | # 'pointsize': '10pt', 148 | 149 | # Additional stuff for the LaTeX preamble. 150 | # 151 | # 'preamble': '', 152 | 153 | # Latex figure (float) alignment 154 | # 155 | # 'figure_align': 'htbp', 156 | } 157 | 158 | # Grouping the document tree into LaTeX files. List of tuples 159 | # (source start file, target name, title, author, documentclass 160 | # [howto, manual, or own class]). 161 | latex_documents = [ 162 | (master_doc, 'param_docs.tex', 163 | 'param_docs Documentation', 164 | 'Jochem Smit', 'manual'), 165 | ] 166 | 167 | 168 | # -- Options for manual page output ------------------------------------ 169 | 170 | # One entry per manual page. List of tuples 171 | # (source start file, name, description, authors, manual section). 172 | man_pages = [ 173 | (master_doc, 'param_docs', 174 | 'param_docs Documentation', 175 | [author], 1) 176 | ] 177 | 178 | 179 | # -- Options for Texinfo output ---------------------------------------- 180 | 181 | # Grouping the document tree into Texinfo files. List of tuples 182 | # (source start file, target name, title, author, 183 | # dir menu entry, description, category) 184 | texinfo_documents = [ 185 | (master_doc, 'param_docs', 186 | 'param_docs Documentation', 187 | author, 188 | 'param_docs', 189 | 'One line description of project.', 190 | 'Miscellaneous'), 191 | ] 192 | 193 | 194 | 195 | --------------------------------------------------------------------------------