Skip to content

Commit

Permalink
release commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Jul 31, 2024
1 parent 12a8c3e commit 66e9463
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 90 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/upload-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
Expand All @@ -22,6 +25,3 @@ jobs:
hatch build
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Python based MediaWiki Content Management System frontend

[![Documentation Status](https://readthedocs.org/projects/pywikicms/badge/?version=latest)](https://pywikicms.readthedocs.io/en/latest/?badge=latest)
[![PyPI Status](https://img.shields.io/pypi/v/pyWikiCMS.svg)](https://pypi.python.org/pypi/pyWikiCMS/)
[![Github Actions Build](https://github.com/BITPlan/pyWikiCMS/workflows/Build/badge.svg?branch=master)](https://github.com/BITPlan/pyWikiCMS/actions?query=workflow%3ABuild+branch%3Amaster)
[![pypi](https://img.shields.io/pypi/pyversions/pyWikiCMS)](https://pypi.org/project/pyWikiCMS/)
[![Github Actions Build](https://github.com/BITPlan/pyWikiCMS/actions/workflows/build.yml/badge.svg)](https://github.com/BITPlan/pyWikiCMS/actions/workflows/build.yml)
[![GitHub issues](https://img.shields.io/github/issues/BITPlan/pyWikiCMS.svg)](https://github.com/BITPlan/pyWikiCMS/issues)
[![GitHub issues](https://img.shields.io/github/issues-closed/BITPlan/pyWikiCMS.svg)](https://github.com/BITPlan/pyWikiCMS/issues/?q=is%3Aissue+is%3Aclosed)
[![GitHub](https://img.shields.io/github/license/BITPlan/pyWikiCMS.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![GitHub closed issues](https://img.shields.io/github/issues-closed/BITPlan/pyWikiCMS.svg)](https://github.com/BITPlan/pyWikiCMS/issues/?q=is%3Aissue+is%3Aclosed)
[![API Docs](https://img.shields.io/badge/API-Documentation-blue)](https://BITPlan.github.io/pyWikiCMS/)
[![License](https://img.shields.io/github/license/BITPlan/pyWikiCMS.svg)](https://www.apache.org/licenses/LICENSE-2.0)

[![BITPlan](http://wiki.bitplan.com/images/wiki/thumb/3/38/BITPlanLogoFontLessTransparent.png/198px-BITPlanLogoFontLessTransparent.png)](http://www.bitplan.com)

10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ maintainers = [
{ name = "Wolfgang Fahl", email = "[email protected]" },
]
readme = "README.md"
license = {text = "Apache-2.0"}
license = {text = "Apache-2.0"}
dependencies = [
# https://github.com/WolfgangFahl/nicegui_widgets
"ngwidgets>=0.14.2",
Expand Down Expand Up @@ -68,9 +68,11 @@ test = [
]

[tool.hatch.build.targets.wheel]
packages = [
"frontend",
]
only-include = ["frontend"]

[tool.hatch.build.targets.wheel.sources]
"frontend" = "frontend"


[project.scripts]
wikicms = "frontend.cmsmain:main"
157 changes: 81 additions & 76 deletions scripts/doc
Original file line number Diff line number Diff line change
@@ -1,83 +1,88 @@
#!/bin/bash
# WF 2020-01-31
# create docs for a configurable project
# WF 2024-07-30 - updated

#
# check whether the given command is installed
#
checkinstalled() {
local l_cmd="$1"
which $l_cmd > /dev/null
if [ $? -ne 0 ]
then
echo "$l_cmd need to be installed" 1>&2
exit 1
fi
}
# Extract project name from pyproject.toml
PROJECT_NAME=$(grep "\[project\]" pyproject.toml -A1 | grep name | cut -d '=' -f2 | tr -d ' "')
PACKAGE_NAME=$(grep "\[tool.hatch.build.targets.wheel.sources\]" pyproject.toml -A1 | tail -1 | cut -d '=' -f2 | tr -d ' "')

fixconf() {
local l_year="$1"
local l_author="$2"
conf=conf.py
# fix sys path
# https://stackoverflow.com/questions/10324393/sphinx-build-fail-autodoc-cant-import-find-module
grep "# sys.path" $conf
if [ $? -eq 0 ]
then
tmpconf=/tmp/conf$$.py
cat $conf | awk -v author="$l_author" -v year="$l_year" '
BEGIN {
quote="\x27"
squote="\047"
}
/# import os/ { next }
/# import sys/ { next }
/copyright/ {
printf "copyright = %s%s, %s%s\n",squote,year,author,squote
next
}
/author/ {
printf "author = %s%s%s\n",squote,author,squote
next
}
/html_theme = / {
# html_theme = 'alabaster'
printf "html_theme = %ssphinx_rtd_theme%s\n",squote,squote
printf "master_doc = %sindex%s\n",squote,squote
next
}
# add sphinx_rtd extension
/extensions = / {
print $0
printf "\t%ssphinx_rtd_theme%s,\n",squote,squote
printf "\t%ssphinx.ext.napoleon%s,\n",squote,squote
next
}
/# sys.path/ {
print("#https://stackoverflow.com/a/44980548/1497139")
print("import os")
print("import sys")
print("import sphinx_rtd_theme")
printf("basepath=os.path.abspath(%s../..%s)\n",squote,squote)
printf("print(%sadding basepath %%s%s %% (basepath))\n",squote,squote)
print("sys.path.insert(0, basepath)")
printf("print(%ssys.path is now: %%s%s %% (sys.path))\n",squote,squote)
next
}
{ print}' > $tmpconf
#diff $tmpconf $conf
mv $tmpconf $conf
echo "$src/conf.py has been fixed"
fi

# Function to print usage information
print_usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -pr, --project NAME Set the project name (default: $PROJECT_NAME)"
echo " -pa, --package NAME Set the package name (default: $PACKAGE_NAME)"
echo " -d, --deploy Deploy the documentation after building"
echo " -h, --help Display this help message"
}

src=docs/source
checkinstalled sphinx-apidoc
sphinx-apidoc --full -f -o $src .
cd $src
# Parse command line arguments
DEPLOY=false
while [[ "$#" -gt 0 ]]; do
case $1 in
-pr|--project) PROJECT_NAME="$2"; shift ;;
-pa|--package) PACKAGE_NAME="$2"; shift ;;
-d|--deploy) DEPLOY=true ;;
-h|--help) print_usage; exit 0 ;;
*) echo "Unknown parameter: $1"; print_usage; exit 1 ;;
esac
shift
done

# Ensure we're in the correct directory
if [[ ! -d "$PACKAGE_NAME" ]]; then
echo "Error: $PACKAGE_NAME package directory not found. Are you in the correct directory?"
exit 1
fi

# Check if mkdocs is installed
if ! command -v mkdocs &> /dev/null; then
pip install mkdocs mkdocs-material mkdocstrings[python]
fi

# Create or update mkdocs.yml
cat << EOF > mkdocs.yml
site_name: $PROJECT_NAME API Documentation
theme:
name: material
plugins:
- search
- mkdocstrings:
handlers:
python:
setup_commands:
- import sys
- import os
- sys.path.insert(0, os.path.abspath("."))
selection:
docstring_style: google
rendering:
show_source: true
nav:
- API: index.md
EOF

# Create or update index.md
index_md=docs/index.md
mkdir -p docs
cat << EOF > $index_md
# $PROJECT_NAME API Documentation
::: $PACKAGE_NAME
options:
show_submodules: true
EOF

fixconf 2021 "Wolfgang Fahl"
make clean html
if [ "$GHACTIONS" != "ACTIVE" ]
then
open _build/html/index.html
# Ignore DeprecationWarnings during build
export PYTHONWARNINGS="ignore::DeprecationWarning"

# Build the documentation
mkdocs build --config-file ./mkdocs.yml

# Deploy if requested
if [ "$DEPLOY" = true ]; then
mkdocs gh-deploy --force --config-file ./mkdocs.yml
fi

echo "Documentation process completed for $PROJECT_NAME."
8 changes: 8 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# WF 2024-07-31
# prepare a release
scripts/doc -d

# Commit with a message that includes the current ISO timestamp
git commit -a -m "release commit"
git push

0 comments on commit 66e9463

Please sign in to comment.