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

fix: cleanup the precommit and codes #17

Merged
merged 14 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
58 changes: 48 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

# This job installs dependencies, build the book, and pushes it to `gh-pages`
jobs:
build-test-book:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -38,16 +43,9 @@ jobs:
run: python3 -m pip install nox

- name: Build book
run: nox -s docs

# Push the book's HTML to github-pages
- name: Push to GitHub Pages
# Only push if on main branch
if: github.ref == 'refs/heads/main'
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: "./_build/html"
run: |
nox -s linkcheck
nox -s docs-test

# Test for bad links and ensure alt tags for usability
- name: Check HTML using htmlproofer
Expand All @@ -66,3 +64,43 @@ jobs:
name: book-html
path: |
./_build/html

- name: Deploy to gh pages
Copy link
Member

Choose a reason for hiding this comment

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

@Revathyvenugopal162 this looks good. I think we want to use the new deploy to GitHub pages that we are using in our website repo here

Are you open to modifying this to use deploy to GH pages rather than the peaceiris action instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lwasser ,sure, i can revert to that change.

# if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_build/html
keep_files: true
commit_message: "Deploy to GitHub Pages"
publish_branch: gh-pages

# This job installs dependencies, build the project, and uploads the artifact
build-artifact:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: Upgrade pip
run: |
python3 -m pip install --upgrade pip

- name: Install dependencies
run: python3 -m pip install nox

- name: Build project
run: nox -s build-project

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pyos-sphinx-theme-artifact
path: dist/
retention-days: 7
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v4.0.0-alpha.8'
hooks:
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# pyos-sphinx-theme
# ``pyos-sphinx-theme``
[![Documentation Status](https://readthedocs.org/projects/pyos-sphinx-theme/badge/?version=latest)](https://pyos-sphinx-theme.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/pyos-sphinx-theme.svg)](https://badge.fury.io/py/pyos-sphinx-theme)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

A modified version of the [pydata sphinx theme](https://
github.com/pydata/sphinx-theme) for use with the [pyOpenSci](https://pyopensci.org) project.
A modified version of the [PyData Sphinx Theme](github.com/pydata/sphinx-theme) for use with the [pyOpenSci](https://pyopensci.org) project.

## Contributors

Expand Down
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""pyOpenSci Sphinx Theme configuration."""

from pyos_sphinx_theme import __version__

project = "Sphinx pyOpenSci Theme"
project = "pyOpenSci Sphinx Theme"
copyright = "2024"
author = "pyOpenSci"
master_doc = "index"
Expand All @@ -26,7 +27,7 @@
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

html_theme = "pyos_sphinx_theme"
html_title = "pyOpenSci Sphinx Theme"
html_title = project
html_copy_source = True
html_sourcelink_suffix = ""

Expand Down
51 changes: 39 additions & 12 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Build and preview this theme documentation locally.
"""Build and preview this theme documentation locally.

To build with a live-server:

Expand All @@ -9,8 +8,9 @@

nox -s docs -- -r
"""
import nox

import pathlib

import nox

nox.options.reuse_existing_virtualenvs = True
Expand All @@ -32,7 +32,7 @@
BUILD_PARAMETERS = ["-b", "html"]

# Sphinx parameters used to test the build of the guide
TEST_PARAMETERS = ['-W', '--keep-going', '-E', '-a']
TEST_PARAMETERS = ["-W", "--keep-going", "-E", "-a"]

AUTOBUILD_IGNORE = [
"_build",
Expand All @@ -41,6 +41,7 @@
"tmp",
]


@nox.session
def docs(session):
"""Build the packaging guide."""
Expand All @@ -50,18 +51,19 @@ def docs(session):

@nox.session(name="docs-live")
def docs_live(session):
"""
Build and launch a local copy of the guide.
"""Build and launch a local copy of the guide.

This session will use sphinx-autobuild to build the guide and launch a local server so you can
browse it locally. It will automatically rebuild the guide when changes are detected in the source.
browse it locally. It will automatically rebuild the guide when changes are
detected in the source.

It can be used with the language parameter to build a specific translation, for example:

nox -s docs-live -- -D language=es

Note: The docs-live-lang session below is provided as a convenience session for beginner contributors
so they don't need to remember the specific sphinx-build parameters to build a different language.
Note: The docs-live-lang session below is provided as a convenience session for beginner
contributors. so they don't need to remember the specific sphinx-build parameters to
build a different language.
"""
session.install("-e", ".")
cmd = [SPHINX_AUTO_BUILD, *BUILD_PARAMETERS, SOURCE_DIR, OUTPUT_DIR, *session.posargs]
Expand All @@ -72,12 +74,37 @@ def docs_live(session):
# cmd.extend(["--watch", folder])
session.run(*cmd)


@nox.session(name="docs-test")
def docs_test(session):
"""
Build the packaging guide with more restricted parameters.
"""Build the packaging guide with more restricted parameters.

Note: this is the session used in CI/CD to release the guide.
"""
session.install("-e", ".")
session.run(SPHINX_BUILD, *BUILD_PARAMETERS, *TEST_PARAMETERS, SOURCE_DIR, OUTPUT_DIR, *session.posargs)
session.run(
SPHINX_BUILD, *BUILD_PARAMETERS, *TEST_PARAMETERS, SOURCE_DIR, OUTPUT_DIR, *session.posargs
)


@nox.session(name="linkcheck")
def linkcheck(session):
"""Check the links in the documentation."""
session.install("-e", ".")
session.run(
SPHINX_BUILD,
*BUILD_PARAMETERS,
"-b",
"linkcheck",
SOURCE_DIR,
OUTPUT_DIR,
*session.posargs,
)


@nox.session(name="build-project")
def build_project(session):
"""Build the project and create a wheel distribution for pyproject.toml file."""
session.install("build", "twine")
session.run("python", "-m", "build")
session.run("twine", "check", "dist/*")
19 changes: 16 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ dependencies = [
]

license = { file = "LICENSE"}
authors = [
{name = "pyos", email = "[email protected]"},
]
classifiers = [
"Framework :: Sphinx",
"Framework :: Sphinx :: Theme",
Expand Down Expand Up @@ -59,3 +56,19 @@ docs = [

[project.entry-points."sphinx.html_themes"]
"pyos_sphinx_theme" = "pyos_sphinx_theme"

[tool.ruff]
line-length = 100
select = [
"E", # pycodestyle, see https://beta.ruff.rs/docs/rules/#pycodestyle-e-w
"D", # pydocstyle, see https://beta.ruff.rs/docs/rules/#pydocstyle-d
"F", # pyflakes, see https://beta.ruff.rs/docs/rules/#pyflakes-f
"I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i
"N", # pep8-naming, see https://beta.ruff.rs/docs/rules/#pep8-naming-n
]
[tool.ruff.format]
quote-style = "double"

[tool.ruff.lint.isort]
combine-as-imports = true
force-sort-within-sections = true
Loading
Loading