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

Add docs for the cutter #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.4

Choose a reason for hiding this comment

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

Update to latest version

Suggested change
rev: v0.1.4
rev: v0.1.7

hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
7 changes: 6 additions & 1 deletion hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
"""Post-generate hook to be run after project generation."""

print(
"""
Expand Down Expand Up @@ -32,5 +32,10 @@

https://aiidalab.readthedocs.io/en/latest/app_development/publish.html

6. Import your repository to readthedocs.org to automatically build and publish your documentation, with the following instructions:

https://readthedocs.org/dashboard/import/ for the import of your repository.
https://docs.readthedocs.io/en/stable/pull-requests.html for the configuration of pull request previews.

"""
)
19 changes: 19 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
target-version = "py39"

[lint]
extend-select = [
"UP", # pyupgrade
"D", # pydocstyle
]

ignore = [
"UP009",
"D205",
"D212",
"D415",
"D100",
"D103",
]

[lint.pydocstyle]
convention = "google"
19 changes: 8 additions & 11 deletions {{cookiecutter.repo_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
repos:

Choose a reason for hiding this comment

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

I would also suggest to add pre-commit-hooks, at least check-yaml is very useful to catch silly errors. See what I am using in my app.

https://github.com/ispg-group/aiidalab-ispg/blob/d4ab6ce6972b1be45a6669007cb343c99ecec90c/.pre-commit-config.yaml#L7

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+

- repo: https://gitlab.com/pycqa/flake8
rev: '3.8.4'
hooks:
- id: flake8
args: [--count, --show-source, --statistics]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.4
hooks:
# Run the linter.
- id: ruff

Choose a reason for hiding this comment

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

I found this config to be quite helpful: automaticall print the issues, or autofix them if possible.

Suggested change
- id: ruff
- id: ruff
args: [--show-source, --fix]

# Run the formatter.
- id: ruff-format
19 changes: 19 additions & 0 deletions {{cookiecutter.repo_name}}/.readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Read the Docs configuration file for MkDocs projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"

mkdocs:
configuration: mkdocs.yml

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
1 change: 1 addition & 0 deletions {{cookiecutter.repo_name}}/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-

"""
{{cookiecutter.app_title}}
{{cookiecutter.repo_name}}
Expand Down
3 changes: 3 additions & 0 deletions {{cookiecutter.repo_name}}/docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Development

Here may go a few notes on how to contribute the development of the app.
16 changes: 16 additions & 0 deletions {{cookiecutter.repo_name}}/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Introduction

This is the documentation for the `{{cookiecutter.repo_name}}` app.
{{ cookiecutter.short_description }}

## Quick start

To access the app, you should open AiiDAlab platform first by either:

- Log into one of the [open AiiDAlab servers](https://www.aiidalab.net/deployments/).
- Run the AiiDAlab docker container directly [on your local machine](https://aiidalab.readthedocs.io/en/latest/usage/index.html#usage-run-locally).

Once you are in the AiiDAlab platform, you can find the app in the App Store.
[Install it and launch it from there](https://aiidalab.readthedocs.io/en/latest/usage/index.html#install-a-new-app).

Here may go with a few examples of how to use the app.
1 change: 1 addition & 0 deletions {{cookiecutter.repo_name}}/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mkdocs-material~=9
3 changes: 3 additions & 0 deletions {{cookiecutter.repo_name}}/docs/tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Tutorial

Here may go a few notes on how to use the app.
9 changes: 9 additions & 0 deletions {{cookiecutter.repo_name}}/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
site_name: Pseudopotential optimization
nav:
- Home: index.md
- Tutorial: tutorial.md
- Development: development.md
theme:
name: material
markdown_extensions:
- footnotes
19 changes: 19 additions & 0 deletions {{cookiecutter.repo_name}}/ruff.toml

Choose a reason for hiding this comment

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

I would propose to put the ruff configuration to pyproject.toml

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
target-version = "py39"

[lint]
extend-select = [
"UP", # pyupgrade
"D", # pydocstyle

Choose a reason for hiding this comment

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

I would propose to add the isort rule. Also maybe flake8-bugbear which might catch actual bugs.
I am not sure about pydocstyle, given the number of rules we skip below.

See my config (we definitely do not want all the rules I have, just those that are least painful / have most upside)
https://github.com/ispg-group/aiidalab-ispg/blob/main/pyproject.toml

If we enable isort, we should configure aiida, and aiidalab_widgets_base as known-first-party packages so that they are grouped together and separately from others, see
https://github.com/ispg-group/aiidalab-ispg/blob/d4ab6ce6972b1be45a6669007cb343c99ecec90c/pyproject.toml#L49

]

ignore = [
"UP009",

Choose a reason for hiding this comment

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

Please comment on each rule what it is and why it is ignored

"D205",
"D212",
"D415",
"D100",
"D103",
]

[lint.pydocstyle]
convention = "google"