Skip to content

Commit 46ecf01

Browse files
authored
Merge pull request #13 from moremoban/dev
release 0.0.5
2 parents df38491 + 1da75d7 commit 46ecf01

33 files changed

+579
-79
lines changed

.github/workflows/pythonpublish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Set up Python
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: '3.x'
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install setuptools wheel twine
20+
- name: Build and publish
21+
env:
22+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
23+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
24+
run: |
25+
python setup.py sdist bdist_wheel
26+
twine upload dist/*

.gitignore

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ parts/
2525
sdist/
2626
var/
2727
wheels/
28-
pip-wheel-metadata/
2928
share/python-wheels/
3029
*.egg-info/
3130
.installed.cfg
@@ -52,8 +51,10 @@ htmlcov/
5251
nosetests.xml
5352
coverage.xml
5453
*.cover
54+
*.py,cover
5555
.hypothesis/
5656
.pytest_cache/
57+
cover/
5758

5859
# Translations
5960
*.mo
@@ -63,6 +64,7 @@ coverage.xml
6364
*.log
6465
local_settings.py
6566
db.sqlite3
67+
db.sqlite3-journal
6668

6769
# Flask stuff:
6870
instance/
@@ -75,6 +77,7 @@ instance/
7577
docs/_build/
7678

7779
# PyBuilder
80+
.pybuilder/
7881
target/
7982

8083
# Jupyter Notebook
@@ -85,17 +88,23 @@ profile_default/
8588
ipython_config.py
8689

8790
# pyenv
88-
.python-version
91+
# For a library or package, you might want to ignore these files since the code is
92+
# intended to run in multiple environments; otherwise, check them in:
93+
# .python-version
8994

9095
# pipenv
9196
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
9297
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93-
# having no cross-platform support, pipenv may install dependencies that dont work, or not
98+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
9499
# install all needed dependencies.
95100
#Pipfile.lock
96101

97-
# celery beat schedule file
102+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
103+
__pypackages__/
104+
105+
# Celery stuff
98106
celerybeat-schedule
107+
celerybeat.pid
99108

100109
# SageMath parsed files
101110
*.sage.py
@@ -127,6 +136,12 @@ dmypy.json
127136
# Pyre type checker
128137
.pyre/
129138

139+
# pytype static type analyzer
140+
.pytype/
141+
142+
# Cython debug symbols
143+
cython_debug/
144+
130145
# VirtualEnv rules
131146
# Virtualenv
132147
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
@@ -159,6 +174,7 @@ pip-selfcheck.json
159174
# Windows rules
160175
# Windows thumbnail cache files
161176
Thumbs.db
177+
Thumbs.db:encryptable
162178
ehthumbs.db
163179
ehthumbs_vista.db
164180

@@ -264,13 +280,15 @@ flycheck_*.el
264280
# Vim rules
265281
# Swap
266282
[._]*.s[a-v][a-z]
283+
!*.svg # comment out if you don't need vector files
267284
[._]*.sw[a-p]
268285
[._]s[a-rt-v][a-z]
269286
[._]ss[a-gi-z]
270287
[._]sw[a-p]
271288

272289
# Session
273290
Session.vim
291+
Sessionx.vim
274292

275293
# Temporary
276294
.netrwhist
@@ -281,7 +299,7 @@ tags
281299
[._]*.un~
282300

283301
# JetBrains rules
284-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
302+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
285303
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
286304

287305
# User-specific stuff
@@ -311,9 +329,14 @@ tags
311329
# When using Gradle or Maven with auto-import, you should exclude module files,
312330
# since they will be recreated, and may cause churn. Uncomment if using
313331
# auto-import.
332+
# .idea/artifacts
333+
# .idea/compiler.xml
334+
# .idea/jarRepositories.xml
314335
# .idea/modules.xml
315336
# .idea/*.iml
316337
# .idea/modules
338+
# *.iml
339+
# *.ipr
317340

318341
# CMake
319342
cmake-build-*/
@@ -363,6 +386,7 @@ fabric.properties
363386

364387
# SFTP configuration file
365388
sftp-config.json
389+
sftp-config-alt*.json
366390

367391
# Package control specific files
368392
Package Control.last-run
@@ -400,6 +424,10 @@ tmtags
400424
!.vscode/tasks.json
401425
!.vscode/launch.json
402426
!.vscode/extensions.json
427+
*.code-workspace
428+
429+
# Local History for Visual Studio Code
430+
.history/
403431

404432
# Xcode rules
405433
# Xcode
@@ -426,6 +454,9 @@ DerivedData/
426454
*.perspectivev3
427455
!default.perspectivev3
428456

457+
## Gcc Patch
458+
/*.gcno
459+
429460
# Eclipse rules
430461
.metadata
431462
bin/
@@ -477,12 +508,17 @@ local.properties
477508

478509
# Annotation Processing
479510
.apt_generated/
511+
.apt_generated_test/
480512

481513
# Scala IDE specific (Scala & Java development for Eclipse)
482514
.cache-main
483515
.scala_dependencies
484516
.worksheet
485517

518+
# Uncomment this line if you wish to ignore the project description file.
519+
# Typically, this file would be tracked if it contains build/dependency configurations:
520+
#.project
521+
486522
# TortoiseGit rules
487523
# Project-level settings
488524
/.tgitconfig

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
line_length=79
33
# Ignore generated files
44
skip=setup.py, moban/__init__.py
5-
known_third_party=moban, fs, lml, crayons, jinja2, ruamel.yaml, mock, nose
5+
known_third_party=pybars, moban, fs, lml, ruamel.yaml, mock, nose
66
indent=' '
77
multi_line_output=3
88
length_sort=1

.moban.d/CUSTOM_README.rst.jj2

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
{%endblock%}
55

66
{%block features%}
7+
8+
Introduction
9+
==============
10+
711
With `pybars3 <https://github.com/wbond/pybars3>`_, this library allow moban users to
8-
have handlebars template in their next documentation endeavour.
12+
have handlebars template in their next documentation endeavour.
13+
14+
Quick start
15+
============
16+
17+
{% raw %}
18+
.. code-block:: bash
19+
20+
$ moban "<p>{{firstname}} {{lastname}}</p>" --template-type handlebars -d firstname=hello lastname=world
21+
{% endraw %}
22+
23+
Nested input objects
24+
---------------------
25+
26+
{% include "handlebars_example.rst.jj2" %}
27+
928
{%endblock%}

.moban.d/custom_travis.yml.jj2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends 'travis.yml.jj2' %}
2+
3+
{%block custom_python_versions%}
4+
python:
5+
- 3.7
6+
- 3.6
7+
- 3.8
8+
{%endblock%}

.moban.d/handlebars_example.rst.jj2

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Given a data.json file with the following content
2+
3+
.. code-block::
4+
5+
{
6+
"person": {
7+
"firstname": "Yehuda",
8+
"lastname": "Katz",
9+
},
10+
}
11+
12+
13+
.. code-block:: bash
14+
15+
{% raw %}
16+
$ moban --template-type handlebars -c data.json "{{person.firstname}} {{person.lastname}}"
17+
Handlebars-ing <p>{{first... to moban.output
18+
Handlebarsed 1 file.
19+
$ cat moban.output
20+
Yehuda Katz
21+
{% endraw %}
22+
23+
For `handlebars.js` users, yes, the example was copied from handlebarjs.com. The
24+
aim is to show off what we can do.
25+
26+
Let's continue with a bit more fancy feature:
27+
28+
{% raw %}
29+
30+
.. code-block:: bash
31+
32+
$ moban --template-type handlebars -c data.json "{{#with person}}{{firstname}} {{lastname}} {{/with}}"
33+
34+
{% endraw %}
35+
36+
{% include "helper_and_partial.rst.jj2" %}

.moban.d/helper_and_partial.rst.jj2

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Moban's way of `pybar3 usage <https://github.com/wbond/pybars3#usage>`_:
2+
3+
Let's save the following file a `script.py` under `helper_and_partial` folder:
4+
5+
.. code-block:: python
6+
7+
from moban_handlebars.api import Helper, register_partial
8+
9+
register_partial('header', '<h1>People</h1>')
10+
11+
12+
@Helper('list')
13+
def _list(this, options, items):
14+
result = [u'<ul>']
15+
for thing in items:
16+
result.append(u'<li>')
17+
result.extend(options['fn'](thing))
18+
result.append(u'</li>')
19+
result.append(u'</ul>')
20+
return result
21+
22+
And given `data.json` reads as the following:
23+
24+
.. code-block::
25+
26+
{
27+
"people":[
28+
{"name": "Bill", "age": 100},
29+
{"name": "Bob", "age": 90},
30+
{"name": "Mark", "age": 25}
31+
]
32+
}
33+
34+
Let's invoke handlebar template:
35+
{% raw %}
36+
37+
.. code-block:: bash
38+
39+
$ moban --template-type hbs -pd helper_and_partial -c data.json "{{>header}}{{#list people}}{{name}} {{age}}{{/list}}"
40+
Handlebars-ing {{>header}... to moban.output
41+
Handlebarsed 1 file.
42+
$ cat moban.output
43+
<h1>People</h1><ul><li>Bill 100</li><li>Bob 90</li><li>Mark 25</li></ul>
44+
45+
{% endraw %}

.moban.d/level-11-readme.rst.jj2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
REAME
2+
===========
3+
4+
{% include "helper_and_partial.rst.jj2" %}

.moban.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
requires:
2-
- type: git
3-
url: https://github.com/moremoban/pypi-mobans
4-
submodule: true
5-
branch: dev
61
configuration:
72
template_dir:
8-
- "pypi-mobans:templates"
3+
- "git://github.com/moremoban/pypi-mobans?submodule=true&branch=dev!/templates"
4+
- "git://github.com/moremoban/pypi-mobans?submodule=true&branch=dev!/statics"
95
- ".moban.d"
106
configuration: moban-handlebars.yml
117
targets:
@@ -17,8 +13,13 @@ targets:
1713
- test.sh: test.script.jj2
1814
- "moban_handlebars/_version.py": "_version.py.jj2"
1915
- .gitignore: gitignore.jj2
20-
- .travis.yml: travis.yml.jj2
16+
- .travis.yml: custom_travis.yml.jj2
2117
- Pipfile: Pipfile.jj2
2218
- output: CHANGELOG.rst
2319
configuration: changelog.yml
2420
template: CHANGELOG.rst.jj2
21+
- lint.sh: lint.script.jj2
22+
- LICENSE: "mit_license.jj2"
23+
- MANIFEST.in: MANIFEST.in.jj2
24+
- ".github/workflows/pythonpublish.yml": "pythonpublish.yml"
25+
- "tests/regression_tests/level-11-helpers-and-partials/README.rst": "level-11-readme.rst.jj2"

0 commit comments

Comments
 (0)