Skip to content

Commit 3c39d60

Browse files
authored
Merge pull request #65 from moremoban/dev
release 0.2.0
2 parents 55d64f8 + c5e4430 commit 3c39d60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+648
-172
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# moban hashes
22
.moban.hashes
33

4-
54
# Extra rules from https://github.com/github/gitignore/
65
# Python rules
76
# Byte-compiled / optimized / DLL files

.moban.cd/changelog.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
name: moban
22
organisation: moremoban
33
releases:
4+
- changes:
5+
- action: Added
6+
details:
7+
- '`#18`: file exists test'
8+
- "`#23`: custom jinja plugins"
9+
- '`#26`: repr filter'
10+
- "`#47`: allow the expansion of template engine"
11+
- "`#58`: allow template type per template"
12+
- action: Updated
13+
details:
14+
- "`#34`: fix plural message if single file is processed"
15+
date: 11-06-2018
16+
version: 0.2.0
417
- changes:
518
- action: Updated
619
details:

.moban.cd/moban.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ organisation: moremoban
33
author: C. W.
44
contact: wangc_2011@hotmail.com
55
license: MIT
6-
version: 0.1.4
7-
current_version: 0.1.4
8-
release: 0.1.4
6+
version: 0.2.0
7+
current_version: 0.2.0
8+
release: 0.2.0
99
branch: master
1010
command_line_interface: "moban"
1111
entry_point: "moban.main:main"
@@ -15,6 +15,7 @@ keywords:
1515
dependencies:
1616
- pyyaml>=3.11
1717
- jinja2>=2.7.1
18+
- lml==0.0.2
1819
- crayons
1920
description: Yet another jinja2 cli command for static text generation
2021
scm_host: github.com

CHANGELOG.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
Change log
22
================================================================================
33

4+
0.2.0 - 11-06-2018
5+
--------------------------------------------------------------------------------
6+
7+
Added
8+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+
10+
#. `#18 <https://github.com/moremoban/moban/issues/18>`_: file exists test
11+
#. `#23 <https://github.com/moremoban/moban/issues/23>`_: custom jinja plugins
12+
#. `#26 <https://github.com/moremoban/moban/issues/26>`_: repr filter
13+
#. `#47 <https://github.com/moremoban/moban/issues/47>`_: allow the expansion of
14+
template engine
15+
#. `#58 <https://github.com/moremoban/moban/issues/58>`_: allow template type
16+
per template
17+
18+
Updated
19+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
21+
#. `#34 <https://github.com/moremoban/moban/issues/34>`_: fix plural message if
22+
single file is processed
23+
424
0.1.4 - 29-May-2018
525
--------------------------------------------------------------------------------
626

README.rst

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -74,35 +74,34 @@ moban.output will contain::
7474
Usage
7575
================================================================================
7676

77-
usage: moban [-h] [-cd CONFIGURATION_DIR] [-c CONFIGURATION]
78-
[-td [TEMPLATE_DIR [TEMPLATE_DIR ...]]] [-t TEMPLATE]
79-
[--template_type TEMPLATE_TYPE] [-o OUTPUT] [-f] [-m MOBANFILE]
80-
81-
Yet another jinja2 cli command for static text generation
82-
83-
84-
optional arguments
85-
--------------------------------------------------------------------------------
86-
87-
* `-h, --help`
88-
show this help message and exit
89-
* `-cd CONFIGURATION_DIR --configuration_dir CONFIGURATION_DIR`
90-
the directory for configuration file lookup
91-
* `-c CONFIGURATION, --configuration CONFIGURATION`
92-
the dictionary file
93-
* `-td [TEMPLATE_DIR [TEMPLATE_DIR ...]], --template_dir [TEMPLATE_DIR [TEMPLATE_DIR ...]]`
94-
the directories for template file lookup
95-
* `-t TEMPLATE, --template TEMPLATE`
96-
the template file
97-
* `--template_type TEMPLATE_TYPE`
98-
the template type, default is jinja2
99-
* `-o OUTPUT, --output OUTPUT`
100-
the output file
101-
* `-f`
102-
force moban to template all files despite of .moban.hashes
103-
* `-m MOBANFILE, --mobanfile MOBANFILE`
104-
custom moban file
105-
77+
::
78+
79+
80+
usage: moban [-h] [-cd CONFIGURATION_DIR] [-c CONFIGURATION]
81+
[-td [TEMPLATE_DIR [TEMPLATE_DIR ...]]] [-t TEMPLATE] [-o OUTPUT]
82+
[-f] [-m MOBANFILE]
83+
84+
Yet another jinja2 cli command for static text generation
85+
86+
optional arguments:
87+
-h, --help show this help message and exit
88+
-cd CONFIGURATION_DIR, --configuration_dir CONFIGURATION_DIR
89+
the directory for configuration file lookup
90+
-c CONFIGURATION, --configuration CONFIGURATION
91+
the dictionary file
92+
-td [TEMPLATE_DIR [TEMPLATE_DIR ...]], --template_dir [TEMPLATE_DIR [TEMPLATE_DIR ...]]
93+
the directories for template file lookup
94+
-t TEMPLATE, --template TEMPLATE
95+
the template file
96+
-o OUTPUT, --output OUTPUT
97+
the output file
98+
--template_type TEMPLATE_TYPE
99+
the template type, default is jinja2
100+
-f force moban to template all files despite of
101+
.moban.hashes
102+
-m MOBANFILE, --mobanfile MOBANFILE
103+
custom moban file
104+
106105

107106
exit codes
108107
--------------------------------------------------------------------------------
@@ -111,7 +110,7 @@ exit codes
111110
- 1 : has changes
112111
- 2 : error occured
113112

114-
Special Filters
113+
Built-in Filters
115114
================================================================================
116115

117116
split_length
@@ -152,3 +151,16 @@ Here is Grammar in the changelog.yml::
152151

153152
More details can be found in `moban's changelog.yml <https://github.com/moremoban/moban/blob/master/.moban.cd/changelog.yml#L10>`_
154153

154+
`repr`
155+
--------------------------------------------------------------------------------
156+
157+
Returns a single quoted string in the templated file
158+
159+
160+
Built-in Tests
161+
================================================================================
162+
163+
`exists`
164+
--------------------------------------------------------------------------------
165+
166+
Test if a file exists or not

docs/engine.png

12.8 KB
Loading

docs/engine.uml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@startuml
2+
3+
package "moban" {
4+
[engine factory]
5+
[jinja2 engine]
6+
}
7+
8+
[lml]
9+
10+
package "moban-mako" {
11+
[mako engine]
12+
}
13+
14+
package "moban-haml" {
15+
[haml engine]
16+
}
17+
18+
[engine factory] -> [lml] : get all engines
19+
[lml] <-- [jinja2 engine] : register
20+
[lml] <.. [mako engine] : register
21+
[lml] <.. [haml engine] : register
22+
23+
@enduml

docs/extension.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Development guide
2+
=======================
3+
4+
Jinja2 extensions for Moban
5+
------------------------------
6+
7+
Since version 0.2, mobanfile supports an extra field `plugin_dir`, along with
8+
`template_dir`. When you put your own jinja2 filters, tests and globals in
9+
your moban repo, you can let moban know about them via this keyword.
10+
11+
Importantly, you have to have `__init__.py` file in your `plugin_dir`. Otherwise,
12+
your plugins will NOT be loaded.
13+
14+
Jinja2 Filter
15+
*******************
16+
17+
.. literalinclude:: ../moban/filters/repr.py
18+
19+
20+
Jinja2 Test
21+
*******************
22+
23+
.. literalinclude:: ../moban/tests/files.py
24+
25+
Jinja2 Globals
26+
*******************
27+
28+
.. literalinclude:: ../tests/test_engine.py
29+
:lines: 49-61
30+
31+
It is possible to write an installable package including your own jinja2
32+
filters, tests and globals. Please email me for more details.
33+
34+
Template engine extension for Moban
35+
--------------------------------------------------------------------------------
36+
37+
moban version 0.2 started using `lml`_ to employ loose couple plugins. Other
38+
template engines, such as marko, haml can be plugged into moban seamless.
39+
40+
.. image:: engine.png
41+
42+
In order plugin other template engines, it is to write a lml plugin. The following
43+
is an example starting point for any template engine.
44+
45+
.. literalinclude:: ../tests/moban-mako/moban_mako/__init__.py
46+
47+
After you will have finished the engine plugin, you can either place it in `plugin_dir`
48+
in order to get it loaded, or make an installable python package. In the latter case,
49+
please refer to `yehua`_: doing that in less than 5 minutes.
50+
51+
.. _lml: http://lml.readthedocs.io
52+
.. _yehua: http://yehua.readthedocs.io

docs/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@ examples folder.
2121
level-4-single-command/README.rst
2222
level-5-custom-configuration/README.rst
2323
level-6-complex-configuration/README.rst
24+
level-7-use-custom-jinja2-filter-test-n-global/README.rst
2425

2526
For more complex use case, please look at `its usage in pyexcel project <http://pyexcel.readthedocs.io/en/latest/guide.html>`_
2627

28+
Developer Guide
29+
================================================================================
30+
31+
.. toctree::
32+
33+
extension
34+
2735
.. include:: ../CHANGELOG.rst
2836

2937
Indices and tables
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
targets:
2-
- a.output: a.template
2+
- a.output: a.template.jj2

0 commit comments

Comments
 (0)