Skip to content

Commit

Permalink
Merge pull request #386 from astrofrog/sphinx-book-theme
Browse files Browse the repository at this point in the history
Switch to Sphinx book theme and fix documentation warnings
  • Loading branch information
astrofrog authored Aug 17, 2023
2 parents 3a8726b + 3524cfa commit 3274465
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 200 deletions.
9 changes: 6 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ version: 2
build:
image: latest

sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: true

python:
version: 3.6
version: 3.8
install:
- method: pip
path: .
extra_requirements:
- docs
- qt
- all

formats: []
209 changes: 33 additions & 176 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,192 +1,29 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# glue-jupyter documentation build configuration file, created by
# sphinx-quickstart on Wed May 30 10:41:52 2018.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# Configuration file for the Sphinx documentation builder.

# 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 -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "glue-jupyter"
copyright = "2018-2023, Maarten A. Breddels and Thomas Robitaille"
author = "Maarten A. Breddels and Thomas Robitaille"

# -- General configuration ------------------------------------------------
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#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.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'nbsphinx', 'numpydoc',
'nbsphinx',
'numpydoc',
'sphinx_automodapi.automodapi',
'sphinx_automodapi.smart_resolver']

numpydoc_show_class_members = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ['.rst', '.ipynb']

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'glue-jupyter'
copyright = '2018, Maarten A. Breddels'
author = 'Maarten A. Breddels'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.0.1'
# The full version, including alpha/beta/rc tags.
release = '0.0.1'

# 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 patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', '**.ipynb_checkpoints']

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

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True


# -- 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'
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# 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']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'glue-jupyterdoc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'glue-jupyter.tex', 'glue-jupyter Documentation',
'Maarten A. Breddels', 'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'glue-jupyter', 'glue-jupyter Documentation',
[author], 1)
]


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'glue-jupyter', 'glue-jupyter Documentation',
author, 'glue-jupyter', 'One line description of project.',
'Miscellaneous'),
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_cache_limit = 10 # days to keep the cached inventories
intersphinx_mapping = {
# 'sphinx': ('https://www.sphinx-doc.org/en/latest/', None),
'python': ('https://docs.python.org/3.11', None),
# 'matplotlib': ('https://matplotlib.org', None),
# 'numpy': ('https://docs.scipy.org/doc/numpy', None),
# 'astropy': ('http://docs.astropy.org/en/stable/', None),
'echo': ('https://echo.readthedocs.io/en/latest/', None),
'ipywidgets': ('https://ipywidgets.readthedocs.io/en/stable/', None),
'traitlets': ('https://traitlets.readthedocs.io/en/stable/', None),
'glue': ('http://docs.glueviz.org/en/latest/', None),
}
autoclass_content = "both"

default_role = 'obj'
nitpicky = True
Expand All @@ -206,3 +43,23 @@
('py:class', 'glue_vispy_viewers.common.layer_state.VispyLayerState')]

automodapi_inheritance_diagram = False

viewcode_follow_imported_members = False

numpydoc_show_class_members = False
autosummary_generate = True
automodapi_toctreedirnm = "api"

intersphinx_mapping = {
'python': ('https://docs.python.org/3.11', None),
'echo': ('https://echo.readthedocs.io/en/latest/', None),
'ipywidgets': ('https://ipywidgets.readthedocs.io/en/stable/', None),
'traitlets': ('https://traitlets.readthedocs.io/en/stable/', None),
'glue': ('https://glue-core.readthedocs.io/en/latest/', None),
'glue-qt': ('https://docs.glueviz.org/en/latest/', None),
}

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_book_theme"
23 changes: 11 additions & 12 deletions docs/developer_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Understanding how the viewers are written
Glue provides a standard infrastructure for developing custom viewers, which
follows a common pattern regardless of whether these viewers are for the
Jupyter platform, Qt, or other front-ends. This infrastructure is described in
detail in :ref:`glue:state-viewer`, and the different viewers here follow these
detail in :ref:`glue-qt:state-viewer`, and the different viewers here follow these
guidelines.

Linking custom widgets with glue state objects
Expand All @@ -20,7 +20,7 @@ interacting with the data object or the links, you can easily do so.
As described in :doc:`getting_started`, each viewer and viewer layer has an
associated state object, where a state object is a collection of properties.
These properties can have callbacks assigned to them which get called when the
properties change (see :ref:`glue:state-viewer` for more details).
properties change (see :ref:`glue-qt:state-viewer` for more details).

The `ipywidgets <https://ipywidgets.readthedocs.io/en/stable/>`_ package makes
use of `traitlets <https://traitlets.readthedocs.io/en/stable/>`_ which provides
Expand Down Expand Up @@ -93,9 +93,9 @@ data objects, subsets, links, and many other parts of glue. See the following
detailed tutorials to find out about the programmatic API for various key
components of glue:

* :ref:`glue:data_tutorial` - for the data collection, data, and subsets
* :ref:`glue:linking-framework` - for the data linking framework
* :ref:`glue:communication` - for the event framework
* :ref:`glue-qt:data_tutorial` - for the data collection, data, and subsets
* :ref:`glue-qt:linking-framework` - for the data linking framework
* :ref:`glue-qt:communication` - for the event framework

Inspecting glue messages being broadcast
----------------------------------------
Expand All @@ -116,33 +116,32 @@ Adding new viewers via plug-ins

New viewers can be added via the normal glue plug-in infrastructure. One
subtlety is that these new viewers have to be added to the viewer registry
and then created using the generic :func:`~glue_jupyter.app.new_data_viewer`
function. To add a viewer to the registry add an entry_point in your
and then created using the generic :meth:`~glue_jupyter.JupyterApplication.new_data_viewer`
method. To add a viewer to the registry add an entry_point in your
plugin's setup.cfg::

[options.entry_points]
glue.plugins =
my_plugin_viewer = my_plugin_viewer:setup

And then define a setup function in your plugin's __init__.py file::

def setup():
from .viewer import MyPluginViewer
from glue_jupyter.registries import viewer_registry
viewer_registry.add("myviewer",MyPluginViewer)

A MyPluginViewer can now be created in a glue-jupyter app as follows::

>>> from glue_jupyter import jglue
>>> app = jglue()
>>> myviewer = app.new_data_viewer('myviewer')

You can add data to the viewer at creation time::

>>> table = app.load_data('mytable.csv')
>>> myviewer = app.new_data_viewer('myviewer', data=table)

Currently it is not possible to specific other configuration options
at viewer creation time for plug-in viewer; they can still be modified
programmatically
:ref:`glue-jupyter:data_tutorial:Modifying viewers and layers programmatically`
programmatically (see :ref:`glue-qt:programmatic`)
14 changes: 7 additions & 7 deletions glue_jupyter/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ def new_data_viewer(self, *args, **kwargs):
This function can be called directly with the name of a viewer
as the first parameter for any viewer types registered in the
viewer_registry. Thus if a plug-in defines a viewer class as
viewer_registry. Thus if a plug-in defines a viewer class as::
from glue_jupyter.registries import viewer_registry
@viewer_registry("pluginviewer")
class PluginViewer(Viewer):
...
from glue_jupyter.registries import viewer_registry
@viewer_registry("pluginviewer")
class PluginViewer(Viewer):
...
then this viewer can be created in a glue-jupyter app via:
then this viewer can be created in a glue-jupyter app via::
s = app.new_data_viewer('pluginviewer')
s = app.new_data_viewer('pluginviewer')
This is the preferred way to call viewers defined in external plugins.
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ docs =
numpydoc
nbconvert>=6.4.5
nbsphinx
sphinx-rtd-theme
sphinx-book-theme

[options.package_data]
glue_jupyter.table = *.vue
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ commands =
test-visual: playwright install chromium
test-visual: pytest --show-capture=no --pyargs glue_jupyter {posargs} --mpl -m mpl_image_compare --mpl --mpl-generate-summary=html --mpl-results-path={toxinidir}/results --mpl-hash-library={toxinidir}/glue_jupyter/tests/images/{envname}.json --mpl-baseline-path=https://raw.githubusercontent.com/glue-viz/glue-jupyter-visual-tests/main/images/{envname}/
notebooks: python .validate-notebooks.py
docs: sphinx-build -n -b html -d _build/doctrees . _build/html
docs: sphinx-build -W -n -b html -d _build/doctrees . _build/html

[testenv:codestyle]
deps = flake8
Expand Down

0 comments on commit 3274465

Please sign in to comment.