Skip to content

Commit

Permalink
Support mkdocs only
Browse files Browse the repository at this point in the history
  • Loading branch information
twsl committed Sep 29, 2024
1 parent 6ed6a78 commit fa5c899
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 1 deletion.
2 changes: 1 addition & 1 deletion project/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Build](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/actions/workflows/build.yaml/badge.svg)](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/actions/workflows/build.yaml){% if include_docs %}
[![Documentation](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/actions/workflows/docs.yaml/badge.svg)](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/actions/workflows/docs.yaml)
{% if docs_library == "mkdocs" %}[![Docs with MkDocs](https://img.shields.io/badge/MkDocs-docs?style=flat&logo=materialformkdocs&logoColor=white&color=%23526CFE)](https://squidfunk.github.io/mkdocs-material/){% elif docs_library == "sphinx" %}[![Docs with Sphinx](https://img.shields.io/badge/Sphinx-docs?style=flat&logo=sphinx&logoColor=white&color=%230A507A)](https://www.sphinx-doc.org/en/master/){% endif %}{% endif %}
[![Docs with MkDocs](https://img.shields.io/badge/MkDocs-docs?style=flat&logo=materialformkdocs&logoColor=white&color=%23526CFE)](https://squidfunk.github.io/mkdocs-material/){% endif %}
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![linting: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff){% if use_precommit %}
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](.pre-commit-config.yaml){% endif %}
Expand Down
47 changes: 47 additions & 0 deletions project/{% if include_docs %}docs{% endif %}/docs/index.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# {{ project_name }}: {{ project_description }}

Welcome to {{project_name}}'s documentation!

[![Build](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/actions/workflows/build.yaml/badge.svg)](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/actions/workflows/build.yaml){% if include_docs %}
[![Documentation](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/actions/workflows/docs.yaml/badge.svg)](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/actions/workflows/docs.yaml)
[![Docs with MkDocs](https://img.shields.io/badge/MkDocs-docs?style=flat&logo=materialformkdocs&logoColor=white&color=%23526CFE)](https://squidfunk.github.io/mkdocs-material/){% endif %}
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![linting: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff){% if use_precommit %}
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](.pre-commit-config.yaml){% endif %}
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
[![Semantic Versions](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--versions-e10079.svg)](https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}/releases)
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-border.json)](https://github.com/copier-org/copier)
{% if copyright_license == "GNU GPLv3" %}[![License](https://img.shields.io/badge/license-GPLv3-blue)](LICENSE){% elif copyright_license == "MIT" %}[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE){% endif %}


## Features

- `...`


## Installation

With `pip`:
```bash
python -m pip install {{ python_package_distribution_name }}
```

With [`poetry`](https://python-poetry.org/):
```bash
poetry add {{ python_package_distribution_name }}
```

## Usage

```python
import {{ python_package_distribution_name }}

...
```

{% if include_notebooks %}See a more complete example in the [notebooks](notebooks) folder.{% endif %}

## API

Check the [API reference](api/{{ python_package_import_name }}/) for more details.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.md-typeset .md-code__content {
display: block !important;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Test

Put your notebooks here

- {ref}`intro_notebook.ipynb`
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "textblock1",
"metadata": {
"cell_marker": "\"\"\""
},
"source": [
"# Introducing Jupyter Notebooks in mkdocs\n",
"\n",
"This notebook showcases very basic functionality of rendering your jupyter notebooks as tutorials inside your mkdocs documentation.\n",
"\n",
"As part of the python project template, your notebooks will be executed AND rendered at document build time.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "codeblock1",
"metadata": {},
"outputs": [],
"source": [
"def sierpinsky(order: int) -> None:\n",
" \"\"\"Define a method that will create a Sierpinsky triangle of given order,\n",
" and will print it out.\"\"\"\n",
" triangles = [\"*\"]\n",
" for i in range(order):\n",
" spaces = \" \" * (2**i)\n",
" triangles = [spaces + triangle + spaces for triangle in triangles] + [\n",
" triangle + \" \" + triangle for triangle in triangles\n",
" ]\n",
" print(f\"Printing order {order} triangle\")\n",
" print(\"\\n\".join(triangles))"
]
},
{
"cell_type": "markdown",
"id": "textblock2",
"metadata": {
"cell_marker": "\"\"\"",
"lines_to_next_cell": 1
},
"source": [
"Then, call our method a few times. This will happen on the fly during notebook rendering.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "codeblock2",
"metadata": {},
"outputs": [],
"source": [
"for order in range(3):\n",
" sierpinsky(order)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "codeblock3",
"metadata": {},
"outputs": [],
"source": [
"sierpinsky(4)"
]
}
],
"metadata": {
"jupytext": {
"cell_markers": "\"\"\""
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
115 changes: 115 additions & 0 deletions project/{% if include_docs %}docs{% endif %}/mkdocs.yml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
site_name: {{project_name}}
repo_url: https://{{ repository_provider }}/{{ repository_namespace }}/{{ repository_name }}
repo_name: {{ repository_namespace }}/{{ repository_name }}
edit_uri: edit/main/docs/
copyright: Copyright © {{ copyright_year }} {{ author_username }}

nav:
- Home: index.md
- API: $api/{{ python_package_import_name }}.***
- Examples: notebooks/index.md

theme:
name: material
language: en
icon:
repo: fontawesome/brands/github
edit: material/pencil
view: material/eye
features:
- announce.dismiss
- content.code.annotate
- content.code.copy
# - content.code.select
# - content.action.edit
# - content.action.view
- content.tooltips
- navigation.expand
- navigation.footer
- navigation.indexes
- navigation.instant
- navigation.instant.prefetch
- navigation.instant.progress
- navigation.path
- navigation.prune
- navigation.sections
- navigation.tabs
- navigation.tabs.sticky
- navigation.top
- navigation.tracking
- search.suggest
- search.highlight
- toc.follow
font:
text: Roboto
palette:
- media: "(prefers-color-scheme)"
primary: black
toggle:
icon: material/brightness-auto
name: Switch to light mode

- media: "(prefers-color-scheme: light)"
scheme: default
primary: black
toggle:
icon: material/weather-night
name: Switch to dark mode

- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: black
toggle:
icon: material/weather-sunny
name: Switch to light mode

extra_css: # fix ui bug in material theme/mkapi
- styles/extra.css

extra:
generator: false

plugins:
- search
- mkdocs-jupyter
- mkapi
- awesome-pages
- tags
- git-authors
- git-revision-date-localized:
enable_creation_date: false
type: iso_datetime

markdown_extensions:
# Python Markdown
- abbr
- admonition
- attr_list
- def_list
- footnotes
- md_in_html
- toc:
permalink: false

# Python Markdown Extensions
- pymdownx.arithmatex:
generic: true
- pymdownx.betterem:
smart_enable: all
- pymdownx.caret
- pymdownx.details
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.highlight
- pymdownx.inlinehilite
- pymdownx.keys
- pymdownx.mark
- pymdownx.smartsymbols
- pymdownx.snippets
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.tilde

0 comments on commit fa5c899

Please sign in to comment.