Skip to content

Commit

Permalink
Improve sphinx documentation structure
Browse files Browse the repository at this point in the history
Put classes in separate files and use autosummary to generate them.
  • Loading branch information
j4321 committed Oct 18, 2018
1 parent 3116205 commit 05b33e1
Show file tree
Hide file tree
Showing 44 changed files with 460 additions and 177 deletions.
Binary file removed docs/source/.doctrees/environment.pickle
Binary file not shown.
Binary file removed docs/source/.doctrees/index.doctree
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/source/_templates/autosummary/base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. auto{{ objtype }}:: {{ objname }}
9 changes: 9 additions & 0 deletions docs/source/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:show-inheritance:
:members:

.. automethod:: __init__
40 changes: 40 additions & 0 deletions docs/source/_templates/autosummary/module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{ name | escape | underline}}

.. automodule:: {{ fullname }}
:show-inheritance:

{% block functions %}
{% if functions %}
.. rubric:: Functions

.. autosummary::
:toctree: functions
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: Classes

.. autosummary::
:toctree: classes
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: Exceptions

.. autosummary::
:toctree: exceptions
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
13 changes: 0 additions & 13 deletions docs/source/autocomplete.rst

This file was deleted.

29 changes: 0 additions & 29 deletions docs/source/color.rst

This file was deleted.

8 changes: 4 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../..'))


# -- Project information -----------------------------------------------------
Expand All @@ -40,9 +40,8 @@
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.autosummary',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -154,7 +153,7 @@
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'ttkwidgets', 'ttkwidgets Documentation',
author, 'ttkwidgets', 'One line description of project.',
author, 'ttkwidgets', "A collection of widgets for Tkinter's ttk extensions by various authors.",
'Miscellaneous'),
]

Expand All @@ -178,3 +177,4 @@


# -- Extension configuration -------------------------------------------------
autosummary_generate = True
81 changes: 20 additions & 61 deletions docs/source/documentation.rst
Original file line number Diff line number Diff line change
@@ -1,71 +1,30 @@
Documentation
=============
.. currentmodule:: ttkwidgets

Submodules
~~~~~~~~~~
.. toctree::
:hidden:
:glob:
:maxdepth: 1

autocomplete
color
font
frames
:Caption: Packages

Widgets
~~~~~~~
ttkwidgets/*

AutoHideScrollbar
-----------------
.. autoclass:: AutoHideScrollbar
:members:

Calendar
--------
.. autoclass:: Calendar
:members:

CheckboxTreeview
----------------
.. autoclass:: CheckboxTreeview
:members:

DebugWindow
-----------
.. autoclass:: DebugWindow
:members:

ItemsCanvas
-----------
.. autoclass:: ItemsCanvas
:members:
Package structure

LinkLabel
---------
.. autoclass:: LinkLabel
:members:
::

ScaleEntry
----------
.. autoclass:: ScaleEntry
:members:
ttkwidgets
├── autocomplete
├── color
├── font
└── frames

ScrolledListbox
---------------
.. autoclass:: ScrolledListbox
:members:

Table
-----
.. autoclass:: Table
:members:

TickScale
---------
.. autoclass:: TickScale
:members:

TimeLine
--------
.. autoclass:: TimeLine
:members:
=================== =======================
Package Content
=================== =======================
:ref:`ttkwidgets` Miscellanous widgets.
:ref:`autocomplete` Autocompletion widgets.
:ref:`color` Color choosing widgets.
:ref:`font` Font choosing widgets.
:ref:`frames` Frame based widgets.
=================== =======================
37 changes: 0 additions & 37 deletions docs/source/font.rst

This file was deleted.

19 changes: 0 additions & 19 deletions docs/source/frames.rst

This file was deleted.

2 changes: 2 additions & 0 deletions docs/source/genindex.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Index
=====
25 changes: 11 additions & 14 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ A collection of widgets for Tkinter's ttk extensions by various authors


.. toctree::
:maxdepth: 5
:maxdepth: 2
:caption: Contents:

installation
documentation
authors
genindex


License
-------

ttkwidgets: A collection of widgets for Tkinter's ttk extensions by various authors
Copyright (C) RedFantom 2017
Copyright (C) The Python Team
Copyright (C) Mitja Martini 2008
Copyright (C) Russell Adams 2011
Copyright (C) Juliette Monsel 2017
ttkwidgets: A collection of widgets for Tkinter's ttk extensions by various authors.

* Copyright (C) RedFantom 2017
* Copyright (C) The Python Team
* Copyright (C) Mitja Martini 2008
* Copyright (C) Russell Adams 2011
* Copyright (C) Juliette Monsel 2017

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -40,14 +43,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

along with this program. If not, see http://www.gnu.org/licenses/.

Indices and tables
==================

* :ref:`genindex`
* :ref:`search`

.. |Travis| image:: https://travis-ci.org/RedFantom/ttkwidgets.svg?branch=master
:alt: Travis CI Build Status
Expand Down
13 changes: 13 additions & 0 deletions docs/source/ttkwidgets/ttkwidgets.autocomplete.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. _autocomplete:

ttkwidgets.autocomplete
=======================

.. currentmodule:: ttkwidgets.autocomplete

.. autosummary::
:nosignatures:
:toctree: ttkwidgets.autocomplete

AutocompleteCombobox
AutocompleteEntry
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
AutocompleteCombobox
====================

.. currentmodule:: ttkwidgets.autocomplete

.. autoclass:: AutocompleteCombobox
:show-inheritance:
:members:

.. automethod:: __init__
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
AutocompleteEntry
=================

.. currentmodule:: ttkwidgets.autocomplete

.. autoclass:: AutocompleteEntry
:show-inheritance:
:members:

.. automethod:: __init__
21 changes: 21 additions & 0 deletions docs/source/ttkwidgets/ttkwidgets.color.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _color:

ttkwidgets.color
================

.. currentmodule:: ttkwidgets.color

.. rubric:: Functions

.. autofunction:: askcolor

.. rubric:: Classes

.. autosummary::
:nosignatures:
:toctree: ttkwidgets.color

AlphaBar
ColorPicker
ColorSquare
GradientBar
Loading

5 comments on commit 05b33e1

@j4321
Copy link
Member Author

@j4321 j4321 commented on 05b33e1 Oct 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have put the different classes in separate files (they are automatically generated with the autosummary extension). @RedFantom Let me know what you think about the general structure of the documentation, then I can work on standardizing the docstrings.

@RedFantom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good! I'm certainly going to look into doing something similar for ttkthemes as well. I do get a lot of warnings while running make html though, and the autoclasses don't work if I do not enter a full path for them, so instead of: .. autoclass:: AlphaBar, I have to enter .. autoclass:: ttkwidgets.color.AlphaBar. Are you experiencing the same thing, or is it building fine for you? If it does, then I am probably doing something very simple wrong.

@j4321
Copy link
Member Author

@j4321 j4321 commented on 05b33e1 Oct 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RedFantom I do get a lot of warnings too and this is because of formatting issues in the docstrings that I plan to fix later. However the autoclass:: Alphabar works fine for me because the .. currentmodule:: ttkwidgets.color directive tells sphinx where to look for the class. I don't know why it does not work for you. Maybe you can try to delete the folders inside docs/source/ttkwidgets so that make html will regenerate the files.

@RedFantom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That indeed does fix the problem. I wrote some documentation for ttkthemes just now, as it is a lot smaller and thus easier to figure out, and that helped a lot in figuring out what is going on.

The frames and autocomplete packages are not properly indexed yet, and clicking documentation doesn't get me the index of the documentation (I have to open the HTML-files manually), so there must still be some things going wrong.

Because you took the initiative on this: Would you prefer to add ttkwidgets to your own ReadTheDocs account or should I add it to mine?

@j4321
Copy link
Member Author

@j4321 j4321 commented on 05b33e1 Oct 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I have enough permissions on the Github repo to add it to my account so it would be easier if you add it to yours.

When I delete all the auto-generated files and the build folder, one run of make html regenerates everything fine with all the indexing and links. I don't know if the difference comes from the OS or the version (I use sphinx 1.8.0).

Please sign in to comment.