Skip to content
Merged
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
26 changes: 26 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
46 changes: 41 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand All @@ -52,8 +51,10 @@ htmlcov/
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -63,6 +64,7 @@ coverage.xml
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -75,6 +77,7 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
Expand All @@ -85,17 +88,23 @@ profile_default/
ipython_config.py

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

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

# celery beat schedule file
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py
Expand Down Expand Up @@ -127,6 +136,12 @@ dmypy.json
# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# VirtualEnv rules
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
Expand Down Expand Up @@ -159,6 +174,7 @@ pip-selfcheck.json
# Windows rules
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

Expand Down Expand Up @@ -264,13 +280,15 @@ flycheck_*.el
# Vim rules
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
Expand All @@ -281,7 +299,7 @@ tags
[._]*.un~

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

# User-specific stuff
Expand Down Expand Up @@ -311,9 +329,14 @@ tags
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/
Expand Down Expand Up @@ -363,6 +386,7 @@ fabric.properties

# SFTP configuration file
sftp-config.json
sftp-config-alt*.json

# Package control specific files
Package Control.last-run
Expand Down Expand Up @@ -400,6 +424,10 @@ tmtags
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Xcode rules
# Xcode
Expand All @@ -426,6 +454,9 @@ DerivedData/
*.perspectivev3
!default.perspectivev3

## Gcc Patch
/*.gcno

# Eclipse rules
.metadata
bin/
Expand Down Expand Up @@ -477,12 +508,17 @@ local.properties

# Annotation Processing
.apt_generated/
.apt_generated_test/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project

# TortoiseGit rules
# Project-level settings
/.tgitconfig
Expand Down
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
line_length=79
# Ignore generated files
skip=setup.py, moban/__init__.py
known_third_party=moban, fs, lml, crayons, jinja2, ruamel.yaml, mock, nose
known_third_party=pybars, moban, fs, lml, ruamel.yaml, mock, nose
indent=' '
multi_line_output=3
length_sort=1
Expand Down
21 changes: 20 additions & 1 deletion .moban.d/CUSTOM_README.rst.jj2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
{%endblock%}

{%block features%}

Introduction
==============

With `pybars3 <https://github.com/wbond/pybars3>`_, this library allow moban users to
have handlebars template in their next documentation endeavour.
have handlebars template in their next documentation endeavour.

Quick start
============

{% raw %}
.. code-block:: bash

$ moban "<p>{{firstname}} {{lastname}}</p>" --template-type handlebars -d firstname=hello lastname=world
{% endraw %}

Nested input objects
---------------------

{% include "handlebars_example.rst.jj2" %}

{%endblock%}
8 changes: 8 additions & 0 deletions .moban.d/custom_travis.yml.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'travis.yml.jj2' %}

{%block custom_python_versions%}
python:
- 3.7
- 3.6
- 3.8
{%endblock%}
36 changes: 36 additions & 0 deletions .moban.d/handlebars_example.rst.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Given a data.json file with the following content

.. code-block::

{
"person": {
"firstname": "Yehuda",
"lastname": "Katz",
},
}


.. code-block:: bash

{% raw %}
$ moban --template-type handlebars -c data.json "{{person.firstname}} {{person.lastname}}"
Handlebars-ing <p>{{first... to moban.output
Handlebarsed 1 file.
$ cat moban.output
Yehuda Katz
{% endraw %}

For `handlebars.js` users, yes, the example was copied from handlebarjs.com. The
aim is to show off what we can do.

Let's continue with a bit more fancy feature:

{% raw %}

.. code-block:: bash

$ moban --template-type handlebars -c data.json "{{#with person}}{{firstname}} {{lastname}} {{/with}}"

{% endraw %}

{% include "helper_and_partial.rst.jj2" %}
45 changes: 45 additions & 0 deletions .moban.d/helper_and_partial.rst.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Moban's way of `pybar3 usage <https://github.com/wbond/pybars3#usage>`_:

Let's save the following file a `script.py` under `helper_and_partial` folder:

.. code-block:: python

from moban_handlebars.api import Helper, register_partial

register_partial('header', '<h1>People</h1>')


@Helper('list')
def _list(this, options, items):
result = [u'<ul>']
for thing in items:
result.append(u'<li>')
result.extend(options['fn'](thing))
result.append(u'</li>')
result.append(u'</ul>')
return result

And given `data.json` reads as the following:

.. code-block::

{
"people":[
{"name": "Bill", "age": 100},
{"name": "Bob", "age": 90},
{"name": "Mark", "age": 25}
]
}

Let's invoke handlebar template:
{% raw %}

.. code-block:: bash

$ moban --template-type hbs -pd helper_and_partial -c data.json "{{>header}}{{#list people}}{{name}} {{age}}{{/list}}"
Handlebars-ing {{>header}... to moban.output
Handlebarsed 1 file.
$ cat moban.output
<h1>People</h1><ul><li>Bill 100</li><li>Bob 90</li><li>Mark 25</li></ul>

{% endraw %}
4 changes: 4 additions & 0 deletions .moban.d/level-11-readme.rst.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REAME
===========

{% include "helper_and_partial.rst.jj2" %}
15 changes: 8 additions & 7 deletions .moban.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
requires:
- type: git
url: https://github.com/moremoban/pypi-mobans
submodule: true
branch: dev
configuration:
template_dir:
- "pypi-mobans:templates"
- "git://github.com/moremoban/pypi-mobans?submodule=true&branch=dev!/templates"
- "git://github.com/moremoban/pypi-mobans?submodule=true&branch=dev!/statics"
- ".moban.d"
configuration: moban-handlebars.yml
targets:
Expand All @@ -17,8 +13,13 @@ targets:
- test.sh: test.script.jj2
- "moban_handlebars/_version.py": "_version.py.jj2"
- .gitignore: gitignore.jj2
- .travis.yml: travis.yml.jj2
- .travis.yml: custom_travis.yml.jj2
- Pipfile: Pipfile.jj2
- output: CHANGELOG.rst
configuration: changelog.yml
template: CHANGELOG.rst.jj2
- lint.sh: lint.script.jj2
- LICENSE: "mit_license.jj2"
- MANIFEST.in: MANIFEST.in.jj2
- ".github/workflows/pythonpublish.yml": "pythonpublish.yml"
- "tests/regression_tests/level-11-helpers-and-partials/README.rst": "level-11-readme.rst.jj2"
Loading