Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize docs #17

Merged
merged 10 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Caches
__pycache__/
/*cache/
/node_modules/

# Build artifacts
/dist/
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -13,15 +13,15 @@ repos:
- id: no-commit-to-branch
args: ["--branch=main"]
- repo: https://github.com/psf/black
rev: "23.3.0"
rev: "23.12.0"
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.275
rev: v0.1.7
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v4.0.0-alpha.4
hooks:
- id: prettier
13 changes: 8 additions & 5 deletions .readthedocs.yml → .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
post_install:
- pip install poetry
- poetry config virtualenvs.create false
- poetry install --with=docs

python:
install:
- method: pip
path: .
extra_requirements:
- docs
- annlibs

sphinx:
configuration: docs/conf.py
Expand Down
16 changes: 6 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,13 @@ perform competitively in high dimensional spaces.
Development
===========

This project is managed using Poetry_ and pre-commit_.
To get started, run ``pre-commit install`` once and ``poetry install ...``
whenever dependencies have changed. E.g. @flying-sheep runs::

poetry install --with=test --extras=annlibs

This installs all optional (dev) dependencies except for those to build the docs.
pre-commit_ comes into play on every `git commit` after installation.
This project is managed using Hatch_ and pre-commit_. To get started, run ``pre-commit
install`` and ``hatch env create``. Run all commands using ``hatch run python
<command>`` which will ensure the environment is kept up to date. pre-commit_ comes into
play on every `git commit` after installation.

Consult ``pyproject.toml`` for which dependency groups and extras exist,
and the poetry help or user guide for more info on what they are.
and the Hatch help or user guide for more info on what they are.

.. _poetry: https://python-poetry.org/
.. _Hatch: https://hatch.pypa.io/
.. _pre-commit: https://pre-commit.com/
6 changes: 3 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= poetry run sphinx-build
SOURCEDIR = .
BUILDDIR = _build
SPHINXBUILD ?= hatch run sphinx-build
SOURCEDIR = $(CURDIR)
BUILDDIR = $(CURDIR)/_build

# Put it first so that "make" without argument is like "make help".
help:
Expand Down
33 changes: 33 additions & 0 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ fullname | escape | underline}}

.. currentmodule:: {{ module }}

.. add toctree option to make autodoc generate the pages

.. autoclass:: {{ objname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Attributes

.. autosummary::
:toctree: .
{% for item in attributes %}
~{{ fullname }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block methods %}
{% if methods %}
.. rubric:: Methods

.. autosummary::
:toctree: .
{% for item in methods %}
{%- if item != '__init__' %}
~{{ fullname }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
{% endblock %}
27 changes: 15 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os

# -- 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 sphinx_rtd_theme

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

project = "sklearn-ann"
Expand All @@ -31,9 +30,11 @@
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"numpydoc",
"sphinx.ext.napoleon",
"scanpydoc.definition_list_typed_field",
"scanpydoc.rtd_github_links",
"sphinx_issues",
"sphinx.ext.viewcode",
"sphinx.ext.linkcode",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -45,19 +46,21 @@
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

autosummary_generate = True
autodoc_default_options = {
"undoc-members": 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"

# 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_path = [sphinx_rtd_theme.get_html_theme_path()]
html_theme = "sphinx_book_theme"
html_theme_options = dict(
repository_url="https://github.com/frankier/sklearn-ann",
repository_branch=os.environ.get("READTHEDOCS_GIT_IDENTIFIER", "main"),
)
rtd_links_prefix = "src"

autodoc_mock_imports = ["annoy", "faiss", "pynndescent", "nmslib"]
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ tests = [
"pytest-cov>=2.10.1",
]
docs = [
"sphinx>=4.2.0",
"sphinx>=7",
"sphinx-gallery>=0.8.2",
"sphinx-rtd-theme>=0.5.1",
"sphinx-book-theme>=1.1.0rc1",
"sphinx-issues>=1.2.0",
"numpydoc>=1.1.0",
"matplotlib>=3.3.3"
"matplotlib>=3.3.3",
"scanpydoc",
]
annoy = [
"annoy>=1.17.0,<2.0.0",
Expand Down Expand Up @@ -81,6 +82,7 @@ features = [

[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
build-docs = "sphinx-build -M html docs docs/_build"

[tool.hatch.build.targets.wheel]
packages = ["src/sklearn_ann"]
Expand Down