Skip to content

Commit

Permalink
Add basic docs and fixes (#4)
Browse files Browse the repository at this point in the history
* Start adding a basic doc that can be generated

This requires no additional modules to be installed.

* Fix list styles

* use variable purple

* clean up font family application

* more docs and style fixes

* Add lists and tables

This CSS still needs a lot of work.

* fixes for func highlighting

* more fixes

* table fixes

* more fixes

* fix widths

* fixes

* put back

* fix cp year
  • Loading branch information
nonhermitian authored Nov 8, 2020
1 parent 972354a commit d436366
Show file tree
Hide file tree
Showing 12 changed files with 1,263 additions and 53 deletions.
28 changes: 28 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
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)
39 changes: 39 additions & 0 deletions docs/classes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
=======
Classes
=======

.. py:class:: Electron
.. rubric:: Attributes

.. py:attribute:: charge
The charge of the electron.


.. py:attribute:: mass
The mass of the electron.


.. py:attribute:: really_long_named_attribute_that_probably_does_not_fit_nicely
A bit too verbose if you ask me.


.. rubric:: Methods


.. py:attribute:: compute_momentum(velocity)
Compute the electrons velocity.

:param float velocity: The electrons velocity
:return: The computed momentum
:rtype: float
:raises ValueError: You did something wrong





139 changes: 139 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=invalid-name
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain 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('.'))

"""
Sphinx documentation builder
"""

# -- Project information -----------------------------------------------------
project = 'Qiskit sphinx theme'
copyright = '2020, Qiskit Development Team' # pylint: disable=redefined-builtin
author = 'Qiskit Development Team'

import qiskit_sphinx_theme

release = qiskit_sphinx_theme.__version__

rst_prolog = """
.. |version| replace:: {0}
""".format(release)

# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# 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.napoleon',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.extlinks',
'jupyter_sphinx',
'sphinx_autodoc_typehints',
]

# -----------------------------------------------------------------------------
# Autosummary
# -----------------------------------------------------------------------------

autosummary_generate = True

# -----------------------------------------------------------------------------
# Autodoc
# -----------------------------------------------------------------------------

autodoc_default_options = {
'inherited-members': None,
}


# If true, figures, tables and code-blocks are automatically numbered if they
# have a caption.
numfig = True

# A dictionary mapping 'figure', 'table', 'code-block' and 'section' to
# strings that are used for format of figure numbers. As a special character,
# %s will be replaced to figure number.
numfig_format = {
'table': 'Table %s'
}
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# 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 = ['_build', '**.ipynb_checkpoints']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'colorful'

# A boolean that decides whether module names are prepended to all object names
# (for object types where a “module” of some kind is defined), e.g. for
# py:function directives.
add_module_names = False

# A list of prefixes that are ignored for sorting the Python module index
# (e.g., if this is set to ['foo.'], then foo.bar is shown under B, not F).
# This can be handy if you document a project that consists of a single
# package. Works only for the HTML builder currently.
modindex_common_prefix = ['qiskit.']

# -- Configuration for extlinks extension ------------------------------------
# Refer to https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html


# -- 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 = 'qiskit_sphinx_theme' # use the theme in subdir 'theme'

#html_sidebars = {'**': ['globaltoc.html']}
html_last_updated_fmt = '%Y/%m/%d'

html_theme_options = {
'logo_only': True,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': True,
}

autoclass_content = 'both'
15 changes: 15 additions & 0 deletions docs/functions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
=========
Functions
=========

.. py:function:: my_function(input1, input2, input3=None, **kwargs)
A function that does awesome stuff.

:param str input1: The first input.
:param str input2: The second input
:param str input3: The third input (default=`None`).
:return: Did the function work.
:rtype: int
:raises ValueError: If the inputs are not the correct values
:raises TypeError: If the inputs are not strings.
Binary file added docs/images/yi_jing_01_chien.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
###########################################
Qiskit sphinx theme |version| documentation
###########################################


.. toctree::
:maxdepth: 1
:caption: Basic functionality
:hidden:

Structural formatting <structural>
Paragraph-level markup <paragraph>
Lists and tables <lists_tables>
Functions <functions>
Classes <classes>


.. Hiding - Indices and tables
:ref:`genindex`
:ref:`modindex`
:ref:`search`
Loading

0 comments on commit d436366

Please sign in to comment.