Skip to content

Commit

Permalink
Merge pull request #6 from ericpre/setup_docs_build
Browse files Browse the repository at this point in the history
Setup docs build
  • Loading branch information
jlaehne authored Aug 31, 2023
2 parents cbfddce + 5d04ee4 commit 732016f
Show file tree
Hide file tree
Showing 38 changed files with 729 additions and 441 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ jobs:
run: |
ls -R
- name: Install HyperSpy (dev)
run: |
pip install https://github.com/hyperspy/hyperspy/archive/refs/heads/RELEASE_next_major.zip
- name: Install distribution
run: |
pip install --pre --find-links dist holospy[tests]
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ jobs:
python --version
pip --version
- name: Install (HyperSpy dev)
# Need to install hyperspy dev until hyperspy 2.0 is released
run: |
pip install https://github.com/hyperspy/hyperspy/archive/refs/heads/RELEASE_next_major.zip
- name: Install
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/docs/_build/*
/doc/_build/*
/build/*
/dist/*
/holospy.egg-info/*
*__pycache__*
*pyd
.spyproject/*
.idea
.idea
27 changes: 27 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: doc/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- htmlzip

python:
install:
- method: pip
path: .
extra_requirements:
- doc
20 changes: 20 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Changelog
*********

Changelog entries for the development version are available at
https://holospy.readthedocs.io/en/latest/changes.html

0.1.dev0 (UNRELEASED)
=====================

- Add pre-commit configuration file (`#4 <https://github.com/hyperspy/holospy/pull/4>`_)
- Format code using ``black`` and add workflow to check formatting (`#3 <https://github.com/hyperspy/holospy/pull/3>`_).
- Add GitHub workflows to tests and build packages (`#2 <https://github.com/hyperspy/holospy/pull/2>`_).

Initiation (2023-07-23)
=======================

- HoloSpy was split out of the `HyperSpy repository
<https://github.com/hyperspy/hyperspy>`_ on July 23, 2023. The electron
holography functionalities so far developed in HyperSpy were moved to the
`HoloSpy repository <https://github.com/hyperspy/holospy>`_.
104 changes: 104 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
.. _contributing_label:

Contributing
************

HoloSpy is meant to be a community maintained project. We welcome contributions
in the form of bug reports, documentation, code, feature requests, and more.
In the following we refer to some resources to help you make useful contributions.

Issues
======

The `issue tracker <https://github.com/hyperspy/holospy/issues>`_ can be used to
report bugs or propose new features. When reporting a bug, the following is
useful:

- give a minimal example demonstrating the bug,
- copy and paste the error traceback.

Pull Requests
=============

If you want to contribute to the HoloSpy source code, you can send us a
`pull request <https://github.com/hyperspy/holospy/pulls>`_. Small bug fixes or
corrections to the user guide are typically a good starting point. But don't
hesitate also for significant code contributions - if needed, we'll help you
to get the code ready to common standards.

Please refer to the
`HyperSpy developer guide <http://hyperspy.org/hyperspy-doc/current/dev_guide/intro.html>`_
in order to get started and for detailed contributing guidelines.

The :doc:`kikuchipy contributors guide <kikuchipy:dev/index>`, another HyperSpy
extension, also is a valuable resource that can get you started and provides useful
guidelines.

Reviewing
---------

As quality assurance, to improve the code, and to ensure a generalized
functionality, pull requests need to be thoroughly reviewed by at least one
other member of the development team before being merged.

Documentation
=============

The HoloSpy documentation consists of three elements:

- Docstrings following the `numpy standard
<https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard>`_
that document the functionality of individual methods on `GitHub
<https://github.com/hyperspy/holospy>`_.
- The `documentation <https://holospy.readthedocs.io>`_ written using `Sphinx
<https://www.sphinx-doc.org>`_ and hosted on `Read the Docs
<https://holospy.readthedocs.io>`_. The source is part of the `GitHub repository
<https://github.com/hyperspy/holospy/tree/main/doc>`_.
- Jupyter notebooks in the `HoloSpy demos repository
<https://github.com/hyperspy/holospy-demos>`_ on GitHub that provide tutorials and example
workflows.

Improving documentation is always welcome and a good way of starting out to learn the GitHub
functionality. You can contribute through pull requests to the respective repositories.

Code style
==========

HoloSpy follows `Style Guide for Python Code <https://www.python.org/dev/peps/pep-0008/>`_
with `The Black Code style
<https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html>`_.

For `docstrings <https://www.python.org/dev/peps/pep-0257/>`_, we follow the `numpydoc
<https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard>`_ standard.

Package imports should be structured into three blocks with blank lines between
them:

- standard libraries (like ``os`` and ``typing``),
- third party packages (like ``numpy`` and ``hyperspy``),
- and finally ``holospy`` imports.

Writing tests
=============

All functionality in HoloSpy is tested via the `pytest <https://docs.pytest.org>`_
framework. The tests reside in the ``test`` directory. Tests are short methods that call
functions in HoloSpy and compare resulting output values with known answers.
Please refer to the `HyperSpy development guide
<https://hyperspy.org/hyperspy-doc/current/dev_guide/testing.html>`_ for further
information on tests.

Releasing a new version
=======================

HoloSpy versioning follows `semantic versioning <https://semver.org/spec/v2.0.0.html>`_
and the version number is therefore a three-part number: MAJOR.MINOR.PATCH.
Each number will change depending on the type of changes according to the following:

- MAJOR increases when making incompatible API changes,
- MINOR increases when adding functionality in a backwards compatible manner, and
- PATCH increases when making backwards compatible bug fixes.

The process to release a new version that is pushed to `PyPI <https://pypi.org>`_ and
`Conda-Forge <https://conda-forge.org/>`_ is documented in the `Releasing guide
<https://github.com/hyperspy/holospy/blob/main/releasing_guide.md>`_.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

HoloSpy is a Python package extending the functionality for multi-dimensional
data analysis provided by the [HyperSpy](https://hyperspy.org) library. It is
aimed at helping with the analysis of (off-axis) electron holography data.

Go to the documentation for instructions on how to install HoloSpy and start an
analysis: [Read the docs](https://holospy.readthedocs.io).

Everyone is welcome to contribute. Please read our
[contributing guidelines](https://github.com/hyperspy/holospy/blob/main/CONTRIBUTING.rst) and get started!

Development of HoloSpy is documented in the
[changelog](https://github.com/hyperspy/holospy/blob/main/CHANGES.rst).
Empty file removed README.rst
Empty file.
20 changes: 20 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -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 = .
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)
Binary file added doc/_static/hyperspy_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions doc/api/datasets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:mod:`holospy.datasets`
-----------------------

.. automodule:: holospy.datasets
:members:
14 changes: 14 additions & 0 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _reference:

#########
Reference
#########

.. toctree::
:caption: API Reference
:maxdepth: 2

datasets
reconstruct
signals
tools
5 changes: 5 additions & 0 deletions doc/api/reconstruct.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:mod:`holospy.reconstruct`
--------------------------

.. automodule:: holospy.reconstruct
:members:
5 changes: 5 additions & 0 deletions doc/api/signals.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:mod:`holospy.signals.hologram_image`
-------------------------------------

.. automodule:: holospy.signals.hologram_image
:members:
5 changes: 5 additions & 0 deletions doc/api/tools.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:mod:`holospy.tools`
--------------------------

.. automodule:: holospy.tools
:members:
3 changes: 3 additions & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. This is a stub, see the top level CHANGELOG.rst file for the changelog.
.. include:: ../CHANGES.rst
15 changes: 15 additions & 0 deletions doc/citing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Citing HoloSpy
**************

HoloSpy is maintained by the HyperSpy community
<https://github.com/hyperspy/holospy/contributors>`_.

If HoloSpy has been significant to a project that leads to an academic
publication, please acknowledge that fact by citing it. The DOI in the
badge below is the `Concept DOI <https://help.zenodo.org/fag/#versioning>`_ --
it can be used to cite the project without referring to a specific
version. If you are citing HoloSpy because you have used it to process data,
please use the DOI of the specific version that you have employed. You can
find it by clicking on the DOI badge below:

To be updated after first release.
107 changes: 107 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# 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:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- 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('.'))

import numpydoc
from packaging.version import Version

# -- Project information -----------------------------------------------------

project = "HoloSpy"
copyright = "2023, HyperSpy Developers"
author = "HyperSpy Developers"


# -- 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 = [
# numpydoc is necessary to parse the docstring using sphinx
# otherwise the nitpicky option will raise many warnings
# "numpydoc",
"sphinx_favicon",
"sphinx.ext.autodoc",
"sphinx.ext.githubpages",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
]

intersphinx_mapping = {
"dask": ("https://docs.dask.org/en/latest", None),
"hyperspy": ("https://hyperspy.org/hyperspy-doc/current/", None),
"kikuchipy": ("https://kikuchipy.org/en/latest/", None),
"matplotlib": ("https://matplotlib.org/stable", None),
"numpy": ("https://numpy.org/doc/stable", None),
"python": ("https://docs.python.org/3", None),
}

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


# -- 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 = "pydata_sphinx_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"]

html_theme_options = {
"github_url": "https://github.com/hyperspy/holospy",
"icon_links": [
{
"name": "Gitter",
"url": "https://gitter.im/hyperspy/hyperspy",
"icon": "fab fa-gitter",
},
],
"logo": {
"image_light": "_static/hyperspy_logo.png",
"image_dark": "_static/hyperspy_logo.png",
},
"header_links_before_dropdown": 6,
}

# -- Options for sphinx_favicon extension -----------------------------------

favicons = {"rel": "icon", "href": "logo_sq.svg", "type": "image/svg+xml"}

# Check links to API when building documentation
nitpicky = False
# Remove when fixed in hyperspy
nitpick_ignore_regex = [(r"py:.*", r"hyperspy.api.*")]

# -- Options for numpydoc extension -----------------------------------

numpydoc_xref_param_type = True
numpydoc_xref_ignore = {"type", "optional", "default", "of"}

if Version(numpydoc.__version__) >= Version("1.6.0rc0"):
numpydoc_validation_checks = {"all", "ES01", "EX01", "GL02", "GL03", "SA01", "SS06"}

# def setup(app):
# app.add_css_file("custom-styles.css")
3 changes: 3 additions & 0 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. This is a stub, see the top level CONTRIBUTING.rst file for the changelog.
.. include:: ../CONTRIBUTING.rst
Loading

0 comments on commit 732016f

Please sign in to comment.