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

Review feedback #5

Merged
merged 24 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 23 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
18 changes: 11 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ repos:
exclude: \.min\.js$
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.8.0
hooks:
# Run the linter.
- id: ruff
files: panel/
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi ]
- repo: https://github.com/hoxbro/clean_notebook
rev: v0.1.15
hooks:
Expand All @@ -46,6 +45,11 @@ repos:
hooks:
- id: oxipng
stages: [manual]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [panel>=1.5.0]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.13.0
hooks:
Expand Down
57 changes: 37 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,76 @@
# copier-template-panel-extension
# Panel Extension Copier Template

A copier template for creating Panel extensions, leveraging the [pixi](https://github.com/prefix-dev/pixi) package manager to simplify setup and management.
A [*Copier*](https://copier.readthedocs.io/en/stable/) template for creating Panel extensions, leveraging the [Pixi](https://github.com/prefix-dev/pixi) package manager to simplify setup and management.

This template comes pre-configured with essential tools and best practices to help you develop, document, and distribute high-quality Panel-based applications or extensions.
This template comes preconfigured with essential tools and best practices to help you develop, document, and distribute high-quality Panel-based applications or extensions.

* [X] **Hatch-based Packaging**: Managed by [Hatch](https://hatch.pypa.io/latest/install/) for streamlined dependency management and build processes.
* [X] **Linting and Code Quality with [`ruff`](https://github.com/charliermarsh/ruff)**: Fast and configurable linting tool for maintaining consistent code style.
* [X] **Linting and Code Quality with [`ruff`](https://github.com/charliermarsh/ruff)**: A fast and configurable linting tool for maintaining consistent code style.
* [X] **Testing with [`pytest`](https://github.com/pytest-dev/pytest)**: Includes support for async tests and thorough configuration for reliable testing.
* [X] **Documentation Generation**: Leverages [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for beautiful documentation and [mkdocstrings](https://mkdocstrings.github.io/) for automatic API documentation.
* [X] **GitHub Actions CI/CD**: Pre-configured workflows for automated testing, building, and publishing.
* [X] **Pixi Package Management**: Integrated with pixi for efficient and reproducible environment management.
* [X] **GitHub Actions CI/CD**: Preconfigured workflows for automated testing, building, and publishing.
* [X] **Pixi Package Management**: Integrated with Pixi for efficient and reproducible environment management.
* [X] **Update Flexibility**: Easily update your project to newer template versions with minimal disruption.
* [X] **BSD License**: Uses the OSI-approved BSD license, ideal for open-source projects.

For more on pixi, see the [documentation here](https://pixi.sh).
To install and get started with Pixi, please refer to the [Pixi documentation](https://pixi.sh).

## Getting Started

### Step 1 - Create from template
### Step 1 - Create from Template

To create a new Panel extension:

```bash
pixi exec --spec copier --spec ruamel.yaml -- copier copy --trust https://github.com/panel-extensions/copier-template-panel-extension <panel-extension-name>
```

To update to a newer template version:
### Step 2 - Create and Add Remote Repository

Go to Github and create your repository with the <panel-extension-name>. Then set the remote:

```bash
pixi exec --spec copier --spec ruamel.yaml -- copier update --defaults --trust
git remote add origin https://github.com/<github-user>/<panel-extension-name>.git
```

The push your new repository

```bash
git push --set-upstream origin main
```

Note: `copier` will show `Conflict` for files with manual changes during an update—this is normal. As long as there are no merge conflict markers, all patches applied cleanly.
### Step 3 - Set Up GitHub Pages Docs

### Step 2 - Setup GitHub Pages docs
Enable GitHub Pages through **Settings > Pages** on the GitHub toolbar:

Enable GitHub Pages through Settings > Pages on the GitHub toolbar:
<img width="710" alt="image" src="assets/review-feedback.png">

<img width="710" alt="image" src="https://github.com/user-attachments/assets/790f4a3e-31ca-42d7-b36e-27e794a504d1">
On your GitHub repo's **About** section in the sidebar, be sure to add the link to your docs page:

ahuang11 marked this conversation as resolved.
Show resolved Hide resolved
On your GitHub repo's sidebar's About section, be sure to add the link to your docs page and some tags!
https://<github-user>.github.io/<panel-extension-name>/

Copy link
Contributor

@ahuang11 ahuang11 Nov 25, 2024

Choose a reason for hiding this comment

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

I think there's a button to automatically use the GitHub page.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand. Could you make the change?

If your docs page is missing a sidebar, remember to add imports to `src/__init__.py` and add them to `__all__`!
If your docs page is missing a sidebar, remember to add imports to `src/__init__.py` and include them in `__all__`.

### Step 3 - Link to PyPi
### Step 4 - Link to PyPI

Head over to https://pypi.org/manage/account/publishing and fill out the form:
Head over to [PyPI](https://pypi.org/manage/account/publishing) and fill out the form:

<img width="797" alt="image" src="https://github.com/user-attachments/assets/69ea7626-a2df-4fbe-a1d4-d20eb5e0cdd7">

#### Step 4 - Release with a tag
### Step 5 - Release with a Tag

Now, when you've populated the template, you can release to PyPi by making a tag!
Once you've populated the template, you can release to PyPI by creating a tag!

![image](https://github.com/user-attachments/assets/970fe011-2ca4-4018-b541-478ac76d3185)

![image](https://github.com/user-attachments/assets/374cd1ec-b1ea-4aef-b1a7-b2818660b0e8)

## Updating the Template

To update to the latest template version run:

```bash
pixi exec --spec copier --spec ruamel.yaml -- copier update --defaults --trust
```

Note: `copier` will show `Conflict` for files with manual changes during an update. This is normal. As long as there are no merge conflict markers, all patches applied cleanly.
Binary file added assets/review-feedback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion template/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
name: artifact
path: dist
- name: Publish package on PyPi
uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 # v1.10.3
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2
4 changes: 2 additions & 2 deletions template/.github/workflows/ci.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:
environments: ${{ matrix.environment }}{% endraw %}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '{{ minimal_python_version }}'

Expand Down Expand Up @@ -172,4 +172,4 @@ jobs:
name: ui_screenshots_${{ runner.os }}
path: ./ui_screenshots
if-no-files-found: ignore
{%- endraw %}
{%- endraw %}
2 changes: 1 addition & 1 deletion template/.github/workflows/docs.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
{%- endraw -%}
{%- endraw -%}
22 changes: 15 additions & 7 deletions template/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ repos:
exclude: \.min\.js$
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.8.0
hooks:
# Run the import sorter.
- id: ruff
files: panel/
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args: ["check", "--select", "I", "--fix"]
files: "^src/"
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi ]
# Run the linter.
- id: ruff
args: [ --fix ]
- repo: https://github.com/hoxbro/clean_notebook
rev: v0.1.15
hooks:
Expand All @@ -46,6 +49,11 @@ repos:
hooks:
- id: oxipng
stages: [manual]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [panel>=1.5.0]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.13.0
hooks:
Expand Down
40 changes: 32 additions & 8 deletions template/README.md.jinja
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# {{ project_slug }}
# {{ project_slug }}

[![CI](https://img.shields.io/github/actions/workflow/status/{{ github_url[19:] }}/ci.yml?style=flat-square&branch=main)]({{ github_url }}/actions/workflows/ci.yml)
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/{{ project_slug }}?logoColor=white&logo=conda-forge&style=flat-square)](https://prefix.dev/channels/conda-forge/packages/{{ project_slug }})
Expand All @@ -13,6 +13,10 @@

{{ project_slug }}

## Pin your version!

This project is **in its early stages**, so if you find a version that suits your needs, it’s recommended to **pin your version**, as updates may introduce changes.

## Installation

Install it via `pip`:
Expand All @@ -21,27 +25,47 @@ Install it via `pip`:
pip install {{ project_slug }}
```

## Development
## Usage

This project is managed by [pixi](https://pixi.sh).
You can install the package in development mode using:
```python
import {{ project_slug_snake_case }}
```

## Development

```bash
git clone {{ github_url }}
cd {{ project_slug }}
```

For a simple setup use [`uv`](https://docs.astral.sh/uv/):

```bash
uv venv
source .venv/bin/activate # on linux. Similar commands for windows and osx
uv pip install -e .[dev]
pre-commit run install
pytest tests
```

For the full Github Actions setup use [pixi](https://pixi.sh):

```bash
pixi run pre-commit-install
pixi run postinstall
pixi run test
```

## Usage
This repository is based on [copier-template-panel-extension](https://github.com/panel-extensions/copier-template-panel-extension).
To update to the latest template version run:

```python
import {{ project_slug_snake_case }}
```bash
pixi exec --spec copier --spec ruamel.yaml -- copier update --defaults --trust
```

## Contributing
Note: `copier` will show `Conflict` for files with manual changes during an update. This is normal. As long as there are no merge conflict markers, all patches applied cleanly.

## ❤️ Contributing

Contributions are welcome! Please follow these steps to contribute:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Reference

::: src.{{ project_slug_snake_case }}
::: {{ project_slug_snake_case }}
7 changes: 5 additions & 2 deletions template/mkdocs.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ theme:
name: material
logo: 'assets/logo.svg'
features:
- content.copy.code
- content.code.copy
palette:
# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
Expand Down Expand Up @@ -46,14 +46,17 @@ plugins:
- mkdocstrings:
handlers:
python:
paths:
- src
options:
docstring_style: google
docstring_style: numpy
show_if_no_docstring: true
filters:
- "!^_"

watch:
- docs
- src/{{ project_slug_snake_case }}

nav:
- Home: index.md
Expand Down
6 changes: 4 additions & 2 deletions template/pixi.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ platforms = ["osx-arm64", "osx-64", "linux-64", "win-64"]

[tasks]
postinstall = "pip install --no-build-isolation --no-deps --disable-pip-version-check -e ."
docs = "mkdocs serve"
docs-build = "mkdocs build"

[dependencies]
python = ">={{ minimal_python_version[2:].replace('3', '3.') }}"
Expand Down Expand Up @@ -83,7 +81,11 @@ depends_on = ["_install-ui"]
[feature.docs.dependencies]
mkdocs = "*"
mkdocs-material = "*"

mkdocstrings-python = "*"
[feature.docs.tasks]
MarcSkovMadsen marked this conversation as resolved.
Show resolved Hide resolved
docs = "mkdocs serve"
docs-build = "mkdocs build"

[environments]
default = ["test"]
Expand Down
Loading
Loading