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

DM-46368: Add support for building an LTD documentation site #38

Merged
merged 4 commits into from
Sep 26, 2024
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
57 changes: 57 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and upload documentation

"on":
merge_group: {}
pull_request: {}
push:
Copy link
Contributor

Choose a reason for hiding this comment

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

On the DM side we usually do branches: main rather than try to exclude, but this is fine.

Copy link
Contributor Author

@JeremyMcCormick JeremyMcCormick Sep 25, 2024

Choose a reason for hiding this comment

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

This was copied from a SQuaRE template. I have no preference, and this can be changed if you like. The rules defined here are just an optimization so workflows aren't run more than once unnecessarily.

branches-ignore:
# These should always correspond to pull requests, so ignore them for
# the push trigger and let them be triggered by the pull_request
# trigger, avoiding running the workflow twice. This is a minor
# optimization so there's no need to ensure this is comprehensive.
- "dependabot/**"
- "gh-readonly-queue/**"
- "renovate/**"
- "tickets/**"
- "u/**"
release:
types: [published]

jobs:
docs:

runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Install Graphviz
run: sudo apt-get install graphviz

- name: Run tox
uses: lsst-sqre/run-tox@v1
with:
python-version: "3.11"
tox-envs: "docs"
# Add docs-linkcheck when the docs and PyPI package are published
# tox-envs: "docs,docs-linkcheck"
tox-plugins: tox-uv

# Only attempt documentation uploads for tagged releases and pull
# requests from ticket branches in the same repository. This avoids
# version clutter in the docs and failures when a PR doesn't have access
# to secrets.
- name: Upload to LSST the Docs
uses: lsst-sqre/ltd-upload@v1
with:
project: "consdb"
dir: "doc/_build/html"
username: ${{ secrets.LTD_USERNAME }}
password: ${{ secrets.LTD_PASSWORD }}
if: >
github.event_name != 'merge_group'
&& (github.event_name != 'pull_request'
|| startsWith(github.head_ref, 'tickets/'))
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ config.log
version.py
bin/

# pip build
build/

# Pytest
tests/.tests
pytest_session.txt
Expand All @@ -27,5 +30,6 @@ htmlcov
.mypy.ini

# environment
.tox
.venv
.vscode
11 changes: 2 additions & 9 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
"""Sphinx configuration file for an LSST stack package.

This configuration only affects single-package Sphinx documentation builds.
For more information, see:
https://developer.lsst.io/stack/building-single-package-docs.html
This configuration only affects single-package Sphinx documenation builds.
"""

from documenteer.conf.pipelinespkg import * # type: ignore # noqa

project = "consdb"
html_theme_options["logotext"] = project # type: ignore # noqa
html_title = project
html_short_title = project
from documenteer.conf.guide import * # noqa: F403,F401
11 changes: 11 additions & 0 deletions doc/documenteer.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
title = "ConsDB"
copyright = "GNU General Public License v3"

[project.python]
package = "consdb"

[sphinx]
disable_primary_sidebars = [
"index"
]
53 changes: 9 additions & 44 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
.. py:currentmodule:: lsst.consdb
:html_theme.sidebar_secondary.remove:

.. _lsst.consdb:

###########
lsst.consdb
###########

.. Paragraph that describes what this Python module does and links to related modules and frameworks.

.. .. _lsst.consdb-using:

.. Using lsst.consdb
.. =================

.. toctree linking to topics related to using the module's APIs.

.. .. toctree::
.. :maxdepth: 1

.. _lsst.consdb-contributing:

Contributing
============
ConsDB
======

``lsst.consdb`` is developed at https://github.com/lsst-dm/consdb.
You can find Jira issues for this module under the `consdb <https://jira.lsstcorp.org/issues/?jql=project%20%3D%20DM%20AND%20component%20%3D%20consdb>`_ component.

.. If there are topics related to developing this module (rather than using it), link to this from a toctree placed here.

.. .. toctree::
.. :maxdepth: 1

.. .. _lsst.consdb-scripts:

.. Script reference
.. ================

.. .. TODO: Add an item to this toctree for each script reference topic in the scripts subdirectory.

.. .. toctree::
.. :maxdepth: 1

.. .. _lsst.consdb-pyapi:
#############
Documentation
#############

Python API reference
====================
.. toctree::
:maxdepth: 1

.. automodapi:: lsst.consdb
:no-main-docstr:
:no-inheritance-diagram:
user-guide/index
8 changes: 8 additions & 0 deletions doc/user-guide/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##########
User Guide
##########

.. toctree::
:maxdepth: 1

installation
5 changes: 5 additions & 0 deletions doc/user-guide/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
############
Installation
############

installation instructions go here
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ description = "consdb provides support for the Consolidated Database for the `Ve
license = { text = "GPL" }
dependencies = ["fastapi", "requests", "sqlalchemy", "astropy"]
readme = "README.rst"
urls = { documentation = "https://consdb.lsst.io", source_code = "https://github.com/lsst-dm/consdb"}
dynamic = ["version"]

[project.urls]
Homepage = "https://consdb.lsst.io"
Source = "https://github.com/lsst-dm/consdb"

[tool.black]
line-length = 110
target-version = ["py311"]
Expand Down Expand Up @@ -38,4 +41,7 @@ log_level = "DEBUG"
asyncio_mode = "auto"

[project.optional-dependencies]
dev = ["pytest"]
test = ["pytest"]
dev = [
"documenteer[guide] < 2",
]
47 changes: 47 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[tox]
envlist = py,coverage-report,typing,lint,docs,docs-linkcheck
isolated_build = True

[testenv]
description = Run pytest against {envname}.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little worried that the testing here is going to conflict with how we want/need to do testing in per-component subdirectories. Can we leave this out for a docs-only commit?

Copy link
Contributor Author

@JeremyMcCormick JeremyMcCormick Sep 25, 2024

Choose a reason for hiding this comment

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

Unless you plan to use tox for running tests, then this file should not affect anything else. Pytest won't look at this file if you run it directly.

I would suggest we leave this in as it is basically working boilerplate that I copied from another project so that tox -e docs works, as well as the tox github action. It can certainly be altered later if it creates conflicts.

extras =
dev

[testenv:py]
description = Run pytest
commands =
coverage run -m pytest {posargs}

[testenv:coverage-report]
description = Compile coverage from each test run.
skip_install = true
deps = coverage[toml]>=5.0.2
depends =
py
commands =
coverage combine
coverage report

[testenv:typing]
description = Run mypy.
commands =
mypy src/example tests

[testenv:lint]
description = Lint codebase by running pre-commit (Black, isort, Flake8).
skip_install = true
deps =
pre-commit
commands = pre-commit run --all-files

[testenv:docs]
description = Build documentation (HTML) with Sphinx.
commands =
sphinx-build --keep-going -n -W -T -b html -d {envtmpdir}/doctrees doc doc/_build/html

[testenv:docs-linkcheck]
description = Check links in the documentation.
allowlist_externals =
make
commands =
make linkcheck
Loading