Skip to content

Commit

Permalink
Fix documentation pages
Browse files Browse the repository at this point in the history
GitHub: fixes #1053
  • Loading branch information
fabcor-maxiv committed Sep 26, 2023
1 parent 8c1b36a commit 7787998
Show file tree
Hide file tree
Showing 27 changed files with 598 additions and 149 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---


name: "Pages"

concurrency:
group: "pages"
cancel-in-progress: true

on:
push:

jobs:

"pages-build":

runs-on: "ubuntu-22.04"

services:

# The Redis server is necessary to run the app,
# which is necessary to get the Flask routes with `autoflask` directives
redis:
image: "redis"
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- "6379:6379/tcp"

steps:

- name: "Checkout"
uses: "actions/checkout@v4" # tested with v4.0.0

# Use micromamba instead of conda for better performance
- name: "Setup conda environment with micromamba"
uses: "mamba-org/setup-micromamba@v1" # tested with v1.4.4
with:
environment-file: "conda-environment.yml"

- name: "Install dependencies with Poetry"
run: "${MAMBA_EXE} run --name mxcubeweb poetry install"

- name: "Build documentation with Sphinx"
run: "${MAMBA_EXE} run --name mxcubeweb make --directory=./docs/ html"

- name: "Upload artifact for GitHub Pages"
# This could potentially be run only when we intent to deploy...
# ...but it can be useful to have the artifact for debugging
# if: "github.ref_name == github.event.repository.default_branch"
uses: "actions/upload-pages-artifact@v2" # tested with v2.0.0
with:
path: "docs/build/html"

"pages-deploy":

if: "github.ref_name == github.event.repository.default_branch"

environment:
name: "github-pages"
url: "${{ steps.deployment.outputs.page_url }}"

needs:
- "pages-build"

permissions:
pages: "write"
id-token: "write"

runs-on: "ubuntu-22.04"

steps:

- name: "Setup GitHub Pages"
uses: "actions/configure-pages@v3" # tested with v3.0.6

- name: "Deploy to GitHub Pages"
id: "deployment"
uses: "actions/deploy-pages@v2" # tested with 2.0.4


... # EOF
38 changes: 17 additions & 21 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
---


# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
os: "ubuntu-22.04"
tools:
python: "3.11"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"
python: "mambaforge-22.9"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
# TODO jobs:
# TODO post_install:
# TODO - "mamba run poetry install"

commands:
- "mamba env create --file conda-environment.yml"
- "mamba run --name mxcubeweb poetry install"
- "(mamba run --name mxcubeweb redis-server &) && BUILDDIR=${READTHEDOCS_OUTPUT} mamba run --name mxcubeweb make --directory=./docs/ html && mamba run --name mxcubeweb redis-cli shutdown"

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub
# TODO conda:
# TODO environment: "conda-environment.yml"

sphinx:
configuration: "docs/conf.py"

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt

... # EOF
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXOPTS = -c .
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
Expand Down
108 changes: 72 additions & 36 deletions docs/source/conf.py → docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,30 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import shlex
import datetime
import importlib.metadata

import mxcube3


PROJECT_PACKAGE_NAME = "mxcubeweb" # Distribution package (not import package)
PROJECT_PACKAGE_METADATA = importlib.metadata.metadata(PROJECT_PACKAGE_NAME)

PROJECT_SLUG_NAME = PROJECT_PACKAGE_NAME

# This is necessary to for the `autoflask` directive to get access to the routes
server, _ = mxcube3.build_server_and_config(test=True, argv=[])
# This is to avoid `Server.kill_processes`, that makes the build return non-zero
server.flask.testing = True


# -- Sphinx configuration -------------------------------------------------


# 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.
# sys.path.insert(0, os.path.abspath('.'))
sys.path.append(os.path.abspath("../../"))
sys.path.append(os.path.abspath("../../mxcube3/"))
sys.path.append(os.path.abspath("../../mxcube3/HardwareObjects"))
sys.path.append(os.path.abspath("../../mxcube3/HardwareRepository"))

# -- General configuration ------------------------------------------------

Expand All @@ -35,48 +47,48 @@
# ones.
# extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo']
extensions = [
"sphinxcontrib.httpdomain",
"myst_parser",
"sphinxcontrib.autohttp.flask",
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"
source_suffix = {
".rst": "restructuredtext",
".md": "markdown",
}

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = "index"
root_doc = "contents"

# General information about the project.
project = u"MXCuBE3"
copyright = u"2015, MXCuBE Collaboration"
author = u"MXCuBE Collaboration"
project = "MXCuBE-Web"
author = PROJECT_PACKAGE_METADATA["Author"]
copyright = f"{datetime.datetime.today().year}, {author}"

DOCUMENT_DESCRIPTION = f"{project} documentation"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "0.1"
version = PROJECT_PACKAGE_METADATA["Version"]
# The full version, including alpha/beta/rc tags.
release = "0.1"
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down Expand Up @@ -113,7 +125,11 @@
# keep_warnings = False

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# todo_include_todos = False

rst_prolog = f"""
.. |project| replace:: {project}
"""


# -- Options for HTML output ----------------------------------------------
Expand All @@ -125,7 +141,13 @@
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
html_theme_options = {
"description": DOCUMENT_DESCRIPTION,
"github_banner": "true",
"github_button": "true",
"github_repo": "mxcubeweb",
"github_user": "mxcube",
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
Expand All @@ -149,7 +171,7 @@
# 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_static_path = ["_static"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand All @@ -165,7 +187,13 @@
# html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
html_sidebars = {
"**": [
"about.html",
"globaltoc.html",
"searchbox.html",
],
}

# Additional templates that should be rendered to pages, maps page names to
# template names.
Expand Down Expand Up @@ -212,7 +240,7 @@
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = "MXCuBE3doc"
htmlhelp_basename = f"{PROJECT_SLUG_NAME}-doc"

# -- Options for LaTeX output ---------------------------------------------

Expand All @@ -232,10 +260,10 @@
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(
master_doc,
"MXCuBE3.tex",
u"MXCuBE3 Documentation",
u"MXCuBE Collaboration",
root_doc,
"{PROJECT_SLUG_NAME}.tex",
DOCUMENT_DESCRIPTION,
author,
"manual",
),
]
Expand Down Expand Up @@ -265,7 +293,15 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "mxcube3", u"MXCuBE3 Documentation", [author], 1)]
man_pages = [
(
root_doc,
PROJECT_SLUG_NAME,
DOCUMENT_DESCRIPTION,
[author],
1,
),
]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -278,12 +314,12 @@
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"MXCuBE3",
u"MXCuBE3 Documentation",
root_doc,
PROJECT_SLUG_NAME,
project,
author,
"MXCuBE3",
"One line description of project.",
project,
DOCUMENT_DESCRIPTION,
"Miscellaneous",
),
]
Expand Down
6 changes: 0 additions & 6 deletions docs/source/Beamline.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/source/Collection.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/Queue.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/source/Sample.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/SampleCentring.rst

This file was deleted.

Loading

0 comments on commit 7787998

Please sign in to comment.