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

docs: Sphinx + ReadTheDocs #2710

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

python:
install:
- path: docs
extra_requirements:
- docs
build:
Copy link

Choose a reason for hiding this comment

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

Would be awesome if we could add doxygen and graphviz to the readthedocs build environment:
https://docs.readthedocs.io/en/stable/config-file/v2.html#build-apt-packages

Then we could include a command within the conf.py to build the source documentation as well. This can be included in its own section of the docs, perhaps named "API Reference".

Note: Technically the readthedocs agents already include doxygen, but I think being explicit can't hurt!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I've added the doxygen. It is a mess now because it is all in one place instead of using groups or manually curating the api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would appreciate a bit of help. Can you find a way to move the doxygen folder back to /docs/doxygen and not have it loop recursively when running sphinx-autobuild? I have tried adding it to exclude_patterns, but that did not do the trick.

Copy link

Choose a reason for hiding this comment

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

I can have a look, I have limited availability for a while, but can update you if I figure anything out

os: ubuntu-22.04
apt_packages:
- doxygen
- graphviz
tools:
python: "3.11"
sphinx:
configuration: docs/conf.py
6 changes: 3 additions & 3 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PROJECT_BRIEF = "Popular C++ unit testing framework"
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = docs/doxygen
OUTPUT_DIRECTORY = docs/build/doxygen

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -1088,7 +1088,7 @@ IGNORE_PREFIX =
# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
# The default value is: YES.

GENERATE_HTML = YES
GENERATE_HTML = NO

# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
Expand Down Expand Up @@ -1946,7 +1946,7 @@ MAN_LINKS = NO
# captures the structure of the code including all documentation.
# The default value is: NO.

GENERATE_XML = NO
GENERATE_XML = YES

# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://godbolt.org/z/EdoY15q9G)
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)

<!-- SPHINX-START -->

## What is Catch2?

Expand Down Expand Up @@ -101,3 +102,5 @@ This documentation comprises these three parts:
* For discussion or questions please use [our Discord](https://discord.gg/4CWS9zD)
* See who else is using Catch2 in [Open Source Software](docs/opensource-users.md#top)
or [commercially](docs/commercial-users.md#top).

<!-- SPHINX-END -->
9 changes: 9 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Python template
build/
eggs/
.eggs/
*.egg-info/
*.egg

# Sphinx documentation
_build/
52 changes: 52 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import subprocess

from sphinx.application import Sphinx
from pathlib import Path

project = 'Catch2'
copyright = '2023, Martin Hořeňovský'
author = 'Martin Hořeňovský'

extensions = [
"myst_parser",
"sphinx_design",
"sphinx_togglebutton",
"breathe",
]

templates_path = []
exclude_patterns = [
'build',
'_build',
'Thumbs.db',
'.DS_Store',
"Readme.md",
]
source_suffix = [".md"]

html_theme = 'furo'
# html_static_path = ['_static']

myst_enable_extensions = [
"tasklist",
"colon_fence",
]

breathe_projects = {
"Catch2": "build/doxygen/xml",
}
breathe_default_project = "Catch2"


def generate_doxygen_xml(app: Sphinx):
"""
Run the doxygen commands
"""
os.chdir(Path(app.confdir).parent)
subprocess.run(["doxygen"])


def setup(app: Sphinx):
# Add hook for building doxygen xml when needed
app.connect("builder-inited", generate_doxygen_xml)
10 changes: 10 additions & 0 deletions docs/developer_api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Developer's API

This is a placeholder for all generated APIs.

These should be organized using [doxygen groups](https://www.doxygen.nl/manual/grouping.html).

## All APIs

:::{doxygenindex}
:::
22 changes: 22 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Catch2

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later.

:::{include} ../README.md
---
start-after: <!-- SPHINX-START -->
end-before: <!-- SPHINX-END -->
---
:::

## Contents

:::{toctree}
---
maxdepth: 2
titlesonly: true
glob: true
---
developer_api/index
/*
:::
25 changes: 25 additions & 0 deletions docs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "Catch2-dev"
version = "0.0.0"
description = "Development environment for Catch2"


[project.optional-dependencies]
docs = [
"sphinx >= 6.0",
"furo",
"sphinx-design",
"sphinx-togglebutton",
"myst-parser",
"breathe",
]
dev = [
"pre-commit",
]

[tool.setuptools]
packages = []