Skip to content
Snippets Groups Projects
Commit 35bdb5b2 authored by Duncan Macleod's avatar Duncan Macleod Committed by Duncan Macleod
Browse files

Improvements to the documentation

A few miscellaneous improvements to the documentation, including some content restructuring and configuration updates
parent 9c161a55
No related branches found
No related tags found
1 merge request!109Improvements to the documentation
...@@ -16,6 +16,7 @@ __pycache__/ ...@@ -16,6 +16,7 @@ __pycache__/
# documentation outputs # documentation outputs
/docs/_build/ /docs/_build/
/docs/api/ /docs/api/*.rst
!/docs/api/gwdatafind.rst
!/docs/api/gwdatafind.utils.rst !/docs/api/gwdatafind.utils.rst
*.automodapi *.automodapi
...@@ -50,6 +50,7 @@ include: ...@@ -50,6 +50,7 @@ include:
- component: $CI_SERVER_FQDN/computing/gitlab/components/sphinx/build@1 - component: $CI_SERVER_FQDN/computing/gitlab/components/sphinx/build@1
inputs: inputs:
apt_packages: graphviz
requirements: ".[docs]" requirements: ".[docs]"
......
...@@ -7,8 +7,7 @@ Gravitational-Wave Frame (GWF) files containing data from the current ...@@ -7,8 +7,7 @@ Gravitational-Wave Frame (GWF) files containing data from the current
gravitational-wave detectors. gravitational-wave detectors.
[![PyPI version](https://badge.fury.io/py/gwdatafind.svg)](http://badge.fury.io/py/gwdatafind) [![PyPI version](https://badge.fury.io/py/gwdatafind.svg)](http://badge.fury.io/py/gwdatafind)
[![Linux status](https://git.ligo.org/lscsoft/gwdatafind/badges/main/pipeline.svg)](https://git.ligo.org/lscsoft/gwdatafind/commits/main) [![Conda version](https://img.shields.io/conda/vn/conda-forge/gwdatafind.svg)](https://anaconda.org/conda-forge/gwdatafind/)
[![Windows status](https://ci.appveyor.com/api/projects/status/js6gql8960qa9pkl?svg=true)](https://ci.appveyor.com/project/duncanmmacleod/gwdatafind)
[![License](https://img.shields.io/pypi/l/gwdatafind.svg)](https://choosealicense.com/licenses/gpl-3.0/) [![License](https://img.shields.io/pypi/l/gwdatafind.svg)](https://choosealicense.com/licenses/gpl-3.0/)
[![Documentation status](https://readthedocs.org/projects/gwdatafind/badge/?version=latest)](https://gwdatafind.readthedocs.io/en/latest/?badge=latest) [![Documentation status](https://readthedocs.org/projects/gwdatafind/badge/?version=latest)](https://gwdatafind.readthedocs.io/en/latest/?badge=latest)
......
===================
API documentation
===================
.. automodapi:: gwdatafind
:no-inheritance-diagram:
:no-heading:
:no-main-docstr:
:headings: =-
:skip: Session
Submodules
----------
.. toctree::
api/gwdatafind.utils
############
`gwdatafind`
############
.. automodapi:: gwdatafind
:no-heading:
:headings: =-
##################
`gwdatafind.utils`
##################
.. automodapi:: gwdatafind.utils .. automodapi:: gwdatafind.utils
:no-heading:
...@@ -33,7 +33,7 @@ GWDataFind servers may be operated with support for ...@@ -33,7 +33,7 @@ GWDataFind servers may be operated with support for
`SciTokens <https://scitokens.org>`__, an implementation of `SciTokens <https://scitokens.org>`__, an implementation of
JSON Web Tokens designed for distributed scientific computing. JSON Web Tokens designed for distributed scientific computing.
When using the :doc:`API <api>`, the following keyword arguments When using :doc:`api/gwdatafind`, the following keyword arguments
can be used with all functions to control the use of SciTokens: can be used with all functions to control the use of SciTokens:
``token`` ``token``
...@@ -83,7 +83,7 @@ proxies as authorisation credentials. ...@@ -83,7 +83,7 @@ proxies as authorisation credentials.
This requires the X.509 credential _subject_ to be known to the server This requires the X.509 credential _subject_ to be known to the server
ahead of time. ahead of time.
When using the :doc:`API <api>`, the following keyword arguments When using :doc:`api/gwdatafind`, the following keyword arguments
can be used to control the use of X.509 credentials: can be used to control the use of X.509 credentials:
``cert`` ``cert``
......
================
``gw_data_find``
================
GWDataFind queries can be made using the command-line interface
accessible via module execution (``python -m gwdatafind``) or
the ``gw_data_find`` entry point script:
.. argparse::
:module: gwdatafind.__main__
:func: command_line
:prog: gw_data_find
:nodescription:
# gwdatafind documentation build configuration file # Copyright (C) 2025 Cardiff University
#
# This file is part of GWDataFind.
#
# GWDataFind is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GWDataFind is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# 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 GWDataFind. If not, see <http://www.gnu.org/licenses/>.
"""GWDataFind documentation configuration file."""
from datetime import (
datetime,
timezone,
)
import inspect import sphinx_github_style
import re
import sys
from os import getenv
from pathlib import Path
import gwdatafind import gwdatafind
# -- metadata # -- metadata
project = "gwdatafind" project = "gwdatafind"
copyright = "2018-2025, Cardiff University" copyright = f"{datetime.now(tz=timezone.utc).date().year}, Cardiff University"
author = "Duncan Macleod" author = "Duncan Macleod"
release = gwdatafind.__version__ release = gwdatafind.__version__
version = re.split(r"[\w-]", gwdatafind.__version__)[0] version = release.split("+", 1)[0]
# -- config # -- config
...@@ -26,6 +44,7 @@ default_role = "obj" ...@@ -26,6 +44,7 @@ default_role = "obj"
# -- theme # -- theme
html_theme = "furo" html_theme = "furo"
html_title = f"{project} {version}"
html_theme_options = { html_theme_options = {
"footer_icons": [ "footer_icons": [
...@@ -52,6 +71,7 @@ extensions = [ ...@@ -52,6 +71,7 @@ extensions = [
"sphinx.ext.intersphinx", "sphinx.ext.intersphinx",
"sphinx.ext.napoleon", "sphinx.ext.napoleon",
"sphinx.ext.linkcode", "sphinx.ext.linkcode",
"sphinxarg.ext",
"sphinx_automodapi.automodapi", "sphinx_automodapi.automodapi",
"sphinx_copybutton", "sphinx_copybutton",
"sphinxarg.ext", "sphinxarg.ext",
...@@ -60,99 +80,33 @@ extensions = [ ...@@ -60,99 +80,33 @@ extensions = [
# automodapi # automodapi
automodapi_inherited_members = False automodapi_inherited_members = False
# copybutton
copybutton_prompt_text = " |".join(( # noqa: FLY002
">>>",
r"\.\.\.",
r"\$"
r"In \[\d*\]:",
r" {2,5}\.\.\.:",
" {5,8}: ",
))
copybutton_prompt_is_regexp = True
copybutton_line_continuation_character = "\\"
# intersphinx # intersphinx
intersphinx_mapping = { intersphinx_mapping = {key: (value, None) for key, value in {
"igwn-auth-utils": ( "igwn-auth-utils": "https://igwn-auth-utils.readthedocs.io/en/stable/",
"https://igwn-auth-utils.readthedocs.io/en/stable/", "igwn-segments": "https://igwn-segments.readthedocs.io/en/stable/",
None, "python": "https://docs.python.org/",
), "requests": "https://requests.readthedocs.io/en/stable/",
"igwn-segments": ( "scitokens": "https://scitokens.readthedocs.io/en/stable/",
"https://igwn-segments.readthedocs.io/en/stable/", }.items()}
None,
), # linkcode
"python": ( linkcode_url = sphinx_github_style.get_linkcode_url(
"https://docs.python.org/", blob=sphinx_github_style.get_linkcode_revision("head"),
None, url="https://git.ligo.org/computing/gwdatafind/client",
), )
"requests": ( linkcode_resolve = sphinx_github_style.get_linkcode_resolve(linkcode_url)
"https://requests.readthedocs.io/en/stable/",
None,
),
"scitokens": (
"https://scitokens.readthedocs.io/en/stable/",
None,
),
}
# napoleon # napoleon
napoleon_use_rtype = False napoleon_use_rtype = False
# -- linkcode
def _project_git_ref(version, prefix="v"):
"""Returns the git reference for the given full release version.
"""
# handle builds in CI
if getenv("GITLAB_CI"):
return getenv("CI_COMMIT_REF")
if getenv("GITHUB_ACTIONS"):
return getenv("GITHUB_SHA")
# otherwise use the project metadata
_setuptools_scm_version_regex = re.compile(
r"\+g(\w+)(?:\Z|\.)",
)
if match := _setuptools_scm_version_regex.search(version):
return match.groups()[0]
return f"{prefix}{version}"
PROJECT_GIT_REF = _project_git_ref(release, prefix="")
PROJECT_PATH = Path(gwdatafind.__file__).parent
PROJECT_URL = getenv(
"CI_PROJECT_URL",
"https://git.ligo.org/computing/gwdatafind/client",
)
PROJECT_BLOB_URL = f"{PROJECT_URL}/blob/{PROJECT_GIT_REF}/{PROJECT_PATH.name}"
def linkcode_resolve(domain, info):
"""Determine the URL corresponding to Python object.
"""
if domain != "py" or not info["module"]:
return None
def find_source(module, fullname):
"""Construct a source file reference for an object reference.
"""
# resolve object
obj = sys.modules[module]
for part in fullname.split("."):
obj = getattr(obj, part)
# get filename relative to project
filename = Path(
inspect.getsourcefile(obj), # type: ignore [arg-type]
).relative_to(PROJECT_PATH).as_posix()
# get line numbers of this object
lines, lineno = inspect.findsource(obj)
if lineno:
start = lineno + 1 # 0-index
end = lineno + len(inspect.getblock(lines[lineno:]))
else:
start = end = 0
return filename, start, end
try:
path, start, end = find_source(info["module"], info["fullname"])
except (
AttributeError, # object not found
OSError, # file not found
TypeError, # source for object not found
ValueError, # file not from this project
):
return None
url = f"{PROJECT_BLOB_URL}/{path}"
if start:
url += f"#L{start}-L{end}"
return url
########## ##########
GWDataFind GWDataFind
########## ##########
.. toctree:: The client library for the GWDataFind service.
:hidden:
GWDatafind <self> .. image:: https://badge.fury.io/py/gwdatafind.svg
:target: https://badge.fury.io/py/gwdatafind
:alt: gwdatafind PyPI release badge
The client library for the GWDataFind service. .. image:: https://img.shields.io/conda/vn/conda-forge/gwdatafind.svg
:target: https://anaconda.org/conda-forge/gwdatafind/
:alt: gwdatafind conda-forge release badge
.. image:: https://img.shields.io/pypi/l/gwdatafind.svg
:target: https://choosealicense.com/licenses/gpl-3.0/
:alt: gwdatafind license
.. raw:: html
<br>
.. image:: https://img.shields.io/gitlab/issues/open/computing%2Fgwdatafind%2Fclient?gitlab_url=https%3A%2F%2Fgit.ligo.org
:target: https://git.ligo.org/computing/gwdatafind/client/issues/
:alt: GitLab Issues
.. image:: https://img.shields.io/gitlab/merge-requests/open/computing%2Fgwdatafind%2Fclient?gitlab_url=https%3A%2F%2Fgit.ligo.org
:target: https://git.ligo.org/computing/gwdatafind/client/merge_requests/
:alt: GitLab Merge Requests
.. toctree:: .. toctree::
:caption: Documentation :caption: Documentation
...@@ -21,6 +39,13 @@ The client library for the GWDataFind service. ...@@ -21,6 +39,13 @@ The client library for the GWDataFind service.
.. toctree:: .. toctree::
:caption: Reference :caption: Reference
:maxdepth: 2 :maxdepth: 1
api/gwdatafind
api/gwdatafind.utils
.. toctree::
:caption: Command-line interface
:maxdepth: 1
api commandline
...@@ -70,10 +70,9 @@ RedHat / CentOS / Scientific / Rocky Linux ...@@ -70,10 +70,9 @@ RedHat / CentOS / Scientific / Rocky Linux
dnf install gwdatafind dnf install gwdatafind
See the IGWN Computing Guide software repositories entries for See the IGWN Computing Guide software repositories entries for
`Scientific Linux 7
<https://computing.docs.ligo.org/guide/software/sl7/>`__
or
`Rocky Linux 8 <https://computing.docs.ligo.org/guide/software/rl8/>`__ `Rocky Linux 8 <https://computing.docs.ligo.org/guide/software/rl8/>`__
or
`Rocky Linux 9 <https://computing.docs.ligo.org/guide/software/rl9/>`__
for instructions on how to configure the required IGWN Yum repositories. for instructions on how to configure the required IGWN Yum repositories.
To install the Python 3 library only (and not any command-line entry points): To install the Python 3 library only (and not any command-line entry points):
......
...@@ -63,10 +63,4 @@ Command-line interface ...@@ -63,10 +63,4 @@ Command-line interface
GWDataFind also provides a command-line interface accessible via GWDataFind also provides a command-line interface accessible via
module execution (``python -m gwdatafind``) or the ``gw_data_find`` module execution (``python -m gwdatafind``) or the ``gw_data_find``
entry point script: entry point script. See :doc:`commandline`.
.. argparse::
:module: gwdatafind.__main__
:func: command_line
:prog: gw_data_find
:nodescription:
...@@ -45,11 +45,11 @@ dynamic = [ ...@@ -45,11 +45,11 @@ dynamic = [
[project.optional-dependencies] [project.optional-dependencies]
docs = [ docs = [
"furo", "furo",
"numpydoc", "Sphinx >=4.4.0",
"Sphinx >= 4.4.0",
"sphinx-argparse", "sphinx-argparse",
"sphinx_automodapi", "sphinx-automodapi",
"sphinx-copybutton", "sphinx-copybutton",
"sphinx-github-style",
] ]
test = [ test = [
"pytest >= 3.9.3", "pytest >= 3.9.3",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment