diff --git a/docs/gen_home_pages.py b/docs/gen_home_pages.py new file mode 100644 index 0000000..a9bf118 --- /dev/null +++ b/docs/gen_home_pages.py @@ -0,0 +1,14 @@ +"""Generate the home pages.""" +import mkdocs_gen_files +import os + +# Read README.md from project root +readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md") + +# Read the content of README.md +with open(readme_path, 'r', encoding='utf-8') as f: + content = f.read() + +# Write the content to index.md in the docs directory +with mkdocs_gen_files.open("index.md", "w") as f: + f.write(content) diff --git a/docs/gen_ref_pages.py b/docs/gen_ref_pages.py index 4ba0a74..13ef662 100644 --- a/docs/gen_ref_pages.py +++ b/docs/gen_ref_pages.py @@ -1,7 +1,6 @@ """Generate the code reference pages.""" from pathlib import Path - import mkdocs_gen_files nav = mkdocs_gen_files.Nav() diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index af29054..0000000 --- a/docs/index.md +++ /dev/null @@ -1,11 +0,0 @@ -# Welcome to repo-scaffold - -A Python project template generator that helps you quickly scaffold new Python projects with best practices. - -## Features - -- Modern Python project structure -- Pre-configured development tools -- Documentation setup with MkDocs -- GitHub Actions for CI/CD -- And more... diff --git a/mkdocs.yml b/mkdocs.yml index bc8ff52..7dd24ef 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -16,6 +16,7 @@ plugins: - gen-files: scripts: - docs/gen_ref_pages.py + - docs/gen_home_pages.py - literate-nav: nav_file: SUMMARY.md - mkdocstrings: diff --git a/pyproject.toml b/pyproject.toml index c9976c7..5325665 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ docs = [ "mkdocs-gen-files>=0.5.0", "mkdocs-literate-nav>=0.6.1", "pymdown-extensions>=10.7", - "pymdown-extensions>=10.7", ] [project.scripts] diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/lint.yaml b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/lint.yaml index 48d61c6..a38106e 100644 --- a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/lint.yaml +++ b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/lint.yaml @@ -13,17 +13,7 @@ permissions: pull-requests: write # 用于在 PR 中添加评论 jobs: - setup: - uses: ./.github/workflows/setup.yaml - with: - install-deps: dev - python-version: "{{cookiecutter.max_python_version}}" # 使用最新版本 - secrets: - OP_SERVICE_ACCOUNT_TOKEN: {% raw %}${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}{% endraw %} - PERSONAL_ACCESS_TOKEN: {% raw %}${{ secrets.PERSONAL_ACCESS_TOKEN }}{% endraw %} - - lint: - needs: setup + check: runs-on: ubuntu-latest steps: - name: Checkout code @@ -37,12 +27,15 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v5 + - name: Install dependencies + run: uv sync --extra=dev + - name: Run lint checks id: lint - run: uv tool run nox -s lint + run: uvx nox -s lint continue-on-error: true - - name: Comment on PR + - name: Comment on PR (Lint) if: github.event_name == 'pull_request' && steps.lint.outcome == 'failure' uses: actions/github-script@v7 with: @@ -62,27 +55,20 @@ jobs: if: steps.lint.outcome == 'failure' run: exit 1 - test-all: - needs: setup - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "{{cookiecutter.max_python_version}}" - - - name: Install uv - uses: astral-sh/setup-uv@v5 - - - name: Run tests on all Python versions + - name: Run tests id: test - run: uv tool run nox -s test_all + run: uvx nox -s test_all continue-on-error: true - - name: Comment on PR + - name: Upload coverage reports + if: success() + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml + flags: unittests + + - name: Comment on PR (Tests) if: github.event_name == 'pull_request' && steps.test.outcome == 'failure' uses: actions/github-script@v7 with: @@ -101,3 +87,4 @@ jobs: - name: Check test result if: steps.test.outcome == 'failure' run: exit 1 + diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/gen_home_pages.py b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/gen_home_pages.py new file mode 100644 index 0000000..a9bf118 --- /dev/null +++ b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/gen_home_pages.py @@ -0,0 +1,14 @@ +"""Generate the home pages.""" +import mkdocs_gen_files +import os + +# Read README.md from project root +readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md") + +# Read the content of README.md +with open(readme_path, 'r', encoding='utf-8') as f: + content = f.read() + +# Write the content to index.md in the docs directory +with mkdocs_gen_files.open("index.md", "w") as f: + f.write(content) diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/gen_ref_pages.py b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/gen_ref_pages.py index 5455d8c..59cefa9 100644 --- a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/gen_ref_pages.py +++ b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/gen_ref_pages.py @@ -1,7 +1,6 @@ """Generate the code reference pages.""" from pathlib import Path - import mkdocs_gen_files nav = mkdocs_gen_files.Nav() diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/index.md b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/index.md deleted file mode 100644 index a679ca9..0000000 --- a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/index.md +++ /dev/null @@ -1,17 +0,0 @@ -# {{cookiecutter.project_slug}} - -{{cookiecutter.description}} - -## Installation - -```bash -pip install {{cookiecutter.project_slug}} -``` - -## Quick Start - -[Add quick start guide here] - -## Features - -[List main features here] diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/mkdocs.yml b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/mkdocs.yml index 156f312..abf4812 100644 --- a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/mkdocs.yml +++ b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/mkdocs.yml @@ -16,6 +16,7 @@ plugins: - gen-files: scripts: - docs/gen_ref_pages.py + - docs/gen_home_pages.py - literate-nav: nav_file: SUMMARY.md - mkdocstrings: diff --git a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/pyproject.toml b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/pyproject.toml index 1ee1a10..55e6dd3 100644 --- a/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/pyproject.toml +++ b/repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/pyproject.toml @@ -30,6 +30,7 @@ docs = [ "mkdocstrings>=0.24.0", "mkdocstrings-python>=1.7.5", "mkdocs-gen-files>=0.5.0", + "pymdown-extensions>=10.7", "mkdocs-literate-nav>=0.6.1", ] {% endif %} @@ -46,7 +47,7 @@ build-backend = "hatchling.build" [tool.ruff] line-length = 120 include = ["pyproject.toml", "{{cookiecutter.project_slug}}/**/*.py"] -target-version = "{{cookiecutter.min_python_version}}" +target-version = "py{{ cookiecutter.min_python_version | replace('.', '') }}" [tool.ruff.lint] select = [ diff --git a/uv.lock b/uv.lock index 2b1ec3b..404426c 100644 --- a/uv.lock +++ b/uv.lock @@ -1,4 +1,5 @@ version = 1 +revision = 1 requires-python = ">=3.12" [[package]] @@ -777,7 +778,7 @@ wheels = [ [[package]] name = "repo-scaffold" -version = "0.8.3" +version = "0.9.0" source = { editable = "." } dependencies = [ { name = "click" }, @@ -823,6 +824,7 @@ requires-dist = [ { name = "ruff", specifier = ">=0.9.6" }, { name = "ruff", marker = "extra == 'dev'", specifier = ">=0.9.6" }, ] +provides-extras = ["dev", "docs"] [[package]] name = "requests"