Skip to content

Commit

Permalink
Update documentation and testing logic
Browse files Browse the repository at this point in the history
- Update documentation release scripts to use sphinx-cmake instead of
  embedded the sphinx CMake module;
- Use custom logic instead of 'lowdown' to handle changelog, as it
  doesn't seem to be maintained;
- Update README to indicate support of CMake 3.30;
- Use requirements.txt file to track Python dependencies used for
  testing;
- Update documentation.
  • Loading branch information
buddly27 committed Aug 20, 2024
1 parent a0f8342 commit d6a8bba
Show file tree
Hide file tree
Showing 15 changed files with 262 additions and 160 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9

Expand All @@ -30,21 +30,21 @@ jobs:
sudo apt update
sudo apt install -y doxygen
python -m pip install --upgrade pip
python -m pip install -r ${GITHUB_WORKSPACE}/doc/requirements.txt
mkdir -p ${{runner.workspace}}/build
python -m pip install -r ${{github.workspace}}/doc/requirements.txt
mkdir -p ${{github.workspace}}/build
- name: Build documentation
run: |
export BUILD_DOCS_WITHOUT_CMAKE=1
export PYTHONPATH="${GITHUB_WORKSPACE}/doc/sphinx"
export PYTHONPATH="${{github.workspace}}/doc/sphinx"
sphinx-build -T -E -b html \
"${GITHUB_WORKSPACE}/doc/sphinx" \
"${{runner.workspace}}/build"
"${{github.workspace}}/doc/sphinx" \
"${{github.workspace}}/build"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ${{runner.workspace}}/build
path: ${{github.workspace}}/build

deploy:
environment:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ jobs:
name: "USD-${{ matrix.usd }}-py${{ matrix.python }}"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Create Build Environment
run: |
sudo apt update
sudo apt install -y libgtest-dev ninja-build
pip install pytest pytest-cmake
python -m pip install -r ${{github.workspace}}/test/requirements.txt
mkdir -p ${{github.workspace}}/build
mkdir -p ${{runner.temp}}/USD
Expand All @@ -68,17 +68,17 @@ jobs:
-D "BUILD_DOCS=OFF" \
-D "CMAKE_INCLUDE_PATH=${{runner.temp}}/USD/include" \
-D "CMAKE_LIBRARY_PATH=${{runner.temp}}/USD/lib" \
${GITHUB_WORKSPACE}
..
cmake --build . --config Release
- name: Check for formatting errors
working-directory: ${{github.workspace}}/build
run: |
cmake --build . --target format
STATUS_OUTPUT=$(git -C ${GITHUB_WORKSPACE} status --porcelain)
STATUS_OUTPUT=$(git -C .. status --porcelain)
if [ -n "$STATUS_OUTPUT" ]; then
echo "Code formatting errors found:"
git -C ${GITHUB_WORKSPACE} diff
git -C .. diff
exit 1
else
echo "No formatting errors found."
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ jobs:
name: "USD-${{ matrix.usd }}-py${{ matrix.python }}"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Create Build Environment
run: |
vcpkg install --triplet=x64-windows gtest
pip install pytest pytest-cmake
cmake -E make_directory ${{runner.workspace}}/build
cmake -E make_directory ${{runner.temp}}/USD
python -m pip install -r ${{github.workspace}}\test\requirements.txt
cmake -E make_directory ${{github.workspace}}\build
cmake -E make_directory ${{runner.temp}}\USD
- name: Install USD
working-directory: ${{runner.temp}}/USD
Expand All @@ -66,7 +66,7 @@ jobs:
- name: Configure & Build
shell: bash
working-directory: ${{runner.workspace}}/build
working-directory: ${{github.workspace}}/build
run: |
export PATH="${{runner.temp}}/USD/bin;${{runner.temp}}/USD/lib;${PATH}"
export PYTHONPATH="${{runner.temp}}/USD/lib/python;${PYTHONPATH}"
Expand All @@ -77,26 +77,26 @@ jobs:
-D "BUILD_DOCS=OFF" \
-D "CMAKE_INCLUDE_PATH=${{runner.temp}}/USD/include" \
-D "CMAKE_LIBRARY_PATH=${{runner.temp}}/USD/lib" \
'${{github.workspace}}'
..
cmake --build . --config Release
- name: Check for formatting errors
shell: bash
working-directory: ${{runner.workspace}}/build
working-directory: ${{github.workspace}}/build
run: |
cmake --build . --target format
STATUS_OUTPUT=$(git -C ${GITHUB_WORKSPACE} status --porcelain)
STATUS_OUTPUT=$(git -C .. status --porcelain)
if [ -n "$STATUS_OUTPUT" ]; then
echo "Code formatting errors found:"
git -C ${GITHUB_WORKSPACE} diff
git -C .. diff
exit 1
else
echo "No formatting errors found."
fi
- name: Run Test
shell: bash
working-directory: ${{runner.workspace}}/build
working-directory: ${{github.workspace}}/build
run: ctest -VV -C Release
env:
CTEST_OUTPUT_ON_FAILURE: True
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# USD Notice Framework

[![CMake](https://img.shields.io/badge/CMake-3.20...3.29-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
[![CMake](https://img.shields.io/badge/CMake-3.20...3.30-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
[![test-linux](https://github.com/wdas/unf/actions/workflows/test-linux.yml/badge.svg?branch=main)](https://github.com/wdas/unf/actions/workflows/test-linux.yml)
[![test-windows](https://github.com/wdas/unf/actions/workflows/test-windows.yml/badge.svg?branch=main)](https://github.com/wdas/unf/actions/workflows/test-windows.yml)
[![License](https://img.shields.io/badge/License-Modified%20Apache%202.0-yellow.svg)](https://github.com/wdas/unf/blob/main/LICENSE.txt)
Expand Down
64 changes: 0 additions & 64 deletions cmake/modules/FindSphinx.cmake

This file was deleted.

4 changes: 2 additions & 2 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ file(COPY sphinx DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
configure_file(sphinx/conf.py sphinx/conf.py @ONLY)

sphinx_add_docs(unfDoc
SOURCE "${CMAKE_CURRENT_BINARY_DIR}/sphinx"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/doc"
SOURCE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/sphinx"
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc"
DEPENDS unfApiRefDoc
)

Expand Down
8 changes: 4 additions & 4 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Lowdown==0.2.1
Sphinx==5.1.1
sphinx-rtd-theme==1.0.0
sphinxcontrib-doxylink==1.12.2
Sphinx==7.*
sphinx-cmake==0.*
sphinx-rtd-theme==2.*
sphinxcontrib-doxylink==1.*
91 changes: 91 additions & 0 deletions doc/sphinx/_extensions/changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from datetime import datetime

from docutils import nodes
from docutils.parsers.rst import directives
from sphinx.util.docutils import SphinxDirective


class ReleaseDirective(SphinxDirective):
has_content = True
required_arguments = 1
optional_arguments = 0
option_spec = {
"date": directives.unchanged_required
}

def run(self):
"""Creates a section for release notes with version and date."""
version = self.arguments[0]

# Fetch today's date as default if no date is provided
today_date_str = datetime.now().strftime("%Y-%m-%d")
date_str = self.options.get("date", today_date_str)

try:
parsed_date = datetime.strptime(date_str, "%Y-%m-%d")
release_date = parsed_date.strftime("%e %B %Y")
except ValueError:
raise ValueError(f"Invalid date format: {date_str}")

# Create the version title node
version_node = nodes.strong(text=version)
section_title = nodes.title("", "", version_node)

# Create the section node with a specific ID
section_id = f"release-{version.replace(' ', '-')}"
section = nodes.section(
"", section_title,
ids=[section_id],
classes=["changelog-release"]
)

# Append formatted date
section.append(
nodes.emphasis(text=release_date, classes=["release-date"])
)

# Parse content into a list of changes
content_node = nodes.Element()
self.state.nested_parse(self.content, self.content_offset, content_node)

# Create a bullet list of changes
changes_list = nodes.bullet_list("", classes=["changelog-change-list"])
for child in content_node:
item = nodes.list_item("")
item.append(child)
changes_list.append(item)

section.append(changes_list)

return [section]


class ChangeDirective(SphinxDirective):
has_content = True
required_arguments = 1
optional_arguments = 0

def run(self):
"""Generates a categorized list item for a changelog entry."""
category = self.arguments[0]

# Create a paragraph for the category with specific styling
class_name = f"changelog-category-{category.lower().replace(' ', '-')}"
category_node = nodes.inline(
"", category,
classes=["changelog-category", class_name]
)
paragraph_node = nodes.paragraph("", "", category_node)

# Parse the detailed content under the category
content_node = nodes.container()
self.state.nested_parse(self.content, 0, content_node)
paragraph_node += content_node

return [paragraph_node]


def setup(app):
"""Register extension with Sphinx."""
app.add_directive("release", ReleaseDirective)
app.add_directive("change", ChangeDirective)
62 changes: 62 additions & 0 deletions doc/sphinx/_static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.changelog-release {
position: relative;
}

.changelog-release > h1, h2, h3, h4, h5 {
margin-bottom: 5px;
}

.changelog-release em.release-date {
color: #999;
position: absolute;
line-height: 2.5em;
top: 0;
right: 0;
}

.changelog-release ul.changelog-change-list {
list-style: outside none none;
}

.changelog-release ul.changelog-change-list > li {
list-style: outside none none;
position: relative;
margin: 0;
padding: 8px 0 2px 120px;
border-top: 1px solid #D6D6D6;
}

.rst-content .section .changelog-change-list ul li {
list-style: initial;
}

.changelog-category {
border-right: 3px solid #CCC;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.05), 0px -1px 0px rgba(0, 0, 0, 0.05) inset;
color: #333;
display: inline-block;
font-size: 0.7em;
font-style: normal;
font-weight: bold;
line-height: 14px;
padding: 4px 2px 4px 10px;
text-shadow: 1px 1px 0px #FFF;
text-transform: uppercase;
width: 102px;
position: absolute;
top: 10px;
left: 0px;
background-color: #f8f8f8;
}

.changelog-category-fixed {
border-color: #7C0;
}

.changelog-category-new {
border-color: #11B0E9;
}

.changelog-category-changed {
border-color: #EB3F3F;
}
Loading

0 comments on commit d6a8bba

Please sign in to comment.