Skip to content

Commit

Permalink
Merge pull request #7 from tasuren/develop
Browse files Browse the repository at this point in the history
update: ドキュメント生成にJinja2とmizuを使うようにした。
  • Loading branch information
tuna2134 authored Dec 21, 2022
2 parents c29403c + d4ac676 commit 188a749
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
run: |
source venv/bin/activate
cd docs
make html
python3 -OO build.py
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./docs/build/html
path: ./docs
deploy:
environment:
name: github-pages
Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
Cargo.lock

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -59,8 +60,8 @@ coverage.xml

.DS_Store

# Sphinx documentation
docs/_build/
# Documentation
docs/index.html

# PyCharm
.idea/
Expand All @@ -69,4 +70,4 @@ docs/_build/
.vscode/

# Pyenv
.python-version
.python-version
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

12 changes: 12 additions & 0 deletions docs/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# mizu - Build documentation

from mizu import parse
from jinja2 import Template, Environment, FileSystemLoader

env = Environment(loader=FileSystemLoader('.'), trim_blocks=False)
template = env.get_template('main.tpl')
with open("main.md", "r") as f:
raw = f.read()
text = template.render(content=parse(raw))
with open("index.html", "w") as f:
f.write(text)
11 changes: 11 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document of mizu</title>
</head>
<body><h1>mizu</h1>
</body>
</html>
70 changes: 70 additions & 0 deletions docs/main.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# mizu 💧

[![Version](https://img.shields.io/pypi/v/mizu)](https://pypi.org/project/mizu/)
[![Downloads](https://pepy.tech/badge/mizu)](https://pepy.tech/project/mizu)
[![Downloads](https://pepy.tech/badge/mizu/month)](https://pepy.tech/project/mizu)
[![Downloads](https://pepy.tech/badge/mizu/week)](https://pepy.tech/project/mizu)

Mizu is markdown parser, written by rust and used [pulldown-cmark](https://github.com/raphlinus/pulldown-cmark).

## Installation

```sh
pip install mizu
```

Or

```sh
pip install "mizu @ git+https://github.com/tuna2134/mizu"
```

## Examples
```py
from mizu import parse


parse("# Hello tuna2134")
```

Extension:
```py
from mizu import parse_ext


parse_ext("""
- [ ] test
- [ ] test2
""")
```

## API Reference
### `parse`
This function is parse markdown to html.

**PARAMETERS:**
text (`str`) – Markdown content.

**RETURNS:**
Html content.

**RETURN TYPE:**
str

## `parse_ext`
This function is parse markdown to html.

**PARAMETERS:**
text (`str`) – Markdown content.
tables (`Optional[bool]`) – Enable tables.
footnotes (`Optional[bool]`) – Enable footnotes.
strikethrough (`Optional[bool]`) – Enable strikethrough.
tasklists (`Optional[bool]`) – Enable tasklists.
smart_punctuation (`Optional[bool]`) – Enable smart_punctuation.
heading_attribute (`Optional[bool]`) – Enable heading_attribute.

**RETURNS:**
Html content.

**RETURN TYPE:**
str
10 changes: 10 additions & 0 deletions docs/main.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document of mizu</title>
</head>
<body>{{ content }}</body>
</html>
35 changes: 0 additions & 35 deletions docs/make.bat

This file was deleted.

4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx
furo
mizu
Jinja2
22 changes: 0 additions & 22 deletions docs/source/index.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/modules.rst

This file was deleted.

0 comments on commit 188a749

Please sign in to comment.