Skip to content

Commit

Permalink
release 0.4.1 (#241)
Browse files Browse the repository at this point in the history
* Lower dependencies (#232)

* ✨ port minimum requirement test via pypi-mobans from pyexcel. #187

* 🐛 fix travis ci file

* 🐛 update unit tests

* :wheel_chair: lower the dependencies

* 💄 pump up the version number

* Minor code refactoring (#236)

* 🔨 code refactoring

* 💄 reformat code

* 📚 fix doc build

* 🐛 fix docs build

* Initial prototype for 202 template types (#239)

* 🔨 code refactoring

* 💄 reformat code

* 🔥 remove MobanEngine's reference to the engine class

* 🔨 refactoring the code and un-bury engine instance

* ✨ initial prototype, not tested. #235

* 📚 fix doc build

* 🐛 fix docs build

* 🔨 refactoring. user define template takes precedence

* 🔬 test user define engine

* ✨ associate user defined file extensions with user defined template engine name, i.e. custom_jinja for jinja2, custom_handlebars for handlebars, #235

* ✨ take template types from moban file. related to #233

* 🔨 address the feedback

* 🐛 fix typos and add line feed

* 💄 beautify the code

* 📚 provide documentation on template_types under configuration. fix #237 (#240)

* 📚 update change log.#232, #235

* 💄 address review feedback
  • Loading branch information
chfw authored Feb 28, 2019
1 parent 878c418 commit 217608f
Show file tree
Hide file tree
Showing 33 changed files with 260 additions and 122 deletions.
7 changes: 7 additions & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: moban
organisation: moremoban
releases:
- changes:
- action: Added
details:
- "`#235`: user defined template types so that custom file extensions, template configurations can be controlled by moban user"
- "`#232`: the package dependencies have been fine tuning to lower versions, most of them are dated back to 2017."
date: unreleased
version: 0.4.1
- changes:
- action: Added
details:
Expand Down
12 changes: 6 additions & 6 deletions .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ organisation: moremoban
author: C. W.
contact: wangc_2011@hotmail.com
license: MIT
version: 0.4.0
current_version: 0.4.0
version: 0.4.1
current_version: 0.4.1
release: 0.4.0
branch: master
master: index
Expand All @@ -21,9 +21,9 @@ dependencies:
- ruamel.yaml>=0.15.5
- jinja2>=2.7.1
- lml>=0.0.9
- appdirs==1.4.3
- crayons
- GitPython==2.1.11
- giturlparse
- appdirs>=1.2.0
- crayons>= 0.1.0
- GitPython>=2.0.0
- giturlparse>=0.9.1
description: Yet another jinja2 cli command for static text generation
scm_host: github.com
3 changes: 3 additions & 0 deletions .moban.d/custom_conf.py.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% include "conf.py.jj2" %}

master_doc = "index"
12 changes: 10 additions & 2 deletions .moban.d/travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{% extends 'travis.yml.jj2' %}

{%block extra_matrix %}
matrix:
include:
- python: 2.7
env: MINREQ=1
{%endblock%}

{%block custom_python_versions%}
python:
- pypy-5.3.1
- 3.7-dev
- &pypy2 pypy2.7-6.0
- 3.8-dev
- 3.7
- 3.6
- 3.5
- 2.7
Expand Down
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
sudo: false
dist: xenial
language: python
notifications:
email: false
python:
- pypy-5.3.1
- 3.7-dev
- &pypy2 pypy2.7-6.0
- 3.8-dev
- 3.7
- 3.6
- 3.5
- 2.7
matrix:
include:
- python: 2.7
env: MINREQ=1
before_install:
- if [[ $TRAVIS_PYTHON_VERSION == "2.6" ]]; then pip install flake8==2.6.2; fi
- if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Change log
================================================================================

0.4.1 - unreleased
--------------------------------------------------------------------------------

Added
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#235 <https://github.com/moremoban/moban/issues/235>`_: user defined
template types so that custom file extensions, template configurations can be
controlled by moban user
#. `#232 <https://github.com/moremoban/moban/issues/232>`_: the package
dependencies have been fine tuning to lower versions, most of them are dated
back to 2017.

0.4.0 - 20.02.2019
--------------------------------------------------------------------------------

Expand Down
50 changes: 3 additions & 47 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
project = 'moban'
copyright = '2017-2019 Onni Software Ltd. and its contributors'
author = 'Onni Software Ltd.'

# The short X.Y version
version = '0.4.0'
version = '0.4.1'
# The full version, including alpha/beta/rc tags
release = '0.4.0'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand All @@ -41,15 +39,6 @@
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
Expand All @@ -70,51 +59,16 @@
#
html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']

# -- Extension configuration -------------------------------------------------
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}

# TODO: html_theme not configurable upstream
html_theme = 'default'

Expand All @@ -128,3 +82,5 @@
]
intersphinx_mapping.update({
})

master_doc = "index"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nihao: shijie
hello: shijie
11 changes: 11 additions & 0 deletions docs/level-18-user-defined-template-types/.moban.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
configuration:
template_types:
my_own_type:
base_type: jinja2
file_extensions:
- file_type_of_my_choice
options:
extensions:
- jinja2_time.TimeExtension
targets:
- a.output: a.template.file_type_of_my_choice
35 changes: 35 additions & 0 deletions docs/level-18-user-defined-template-types/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Level 18: User defined template types
================================================================================

Since moban version 4.1, custom template types can be defined to deviate from
default configurations of the template engines. In addition, the configuration
possibilities are:

#. associate your own file extensions
#. choose your own template engine extensions
#.


Evaluation
--------------------------------------------------------------------------------

Please go to `docs/level-4-single-command` directory.


Here is the `.moban.yml`, which inserts `template_types` on top of the moban
file found in level 4::

configuration:
template_types:
my_own_type:
base_type: jinja2
file_extensions:
- file_type_of_my_choice
options:
extensions:
- jinja2_time.TimeExtension
targets:
- a.output: a.template.file_type_of_my_choice


where `template_types` is a dictionary of different custom types
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% now 'utc' %}

2 changes: 2 additions & 0 deletions docs/level-18-user-defined-template-types/data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
overrides: data.base.yaml
hello: world
2 changes: 1 addition & 1 deletion docs/level-4-single-command/.moban.cd/data.base.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nihao: shijie
hello: shijie
hello: shijie
2 changes: 1 addition & 1 deletion docs/level-4-single-command/data.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
overrides: data.base.yaml
hello: world
hello: world
7 changes: 7 additions & 0 deletions min_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ruamel.yaml==0.15.5
jinja2==2.7.1
lml==0.0.9
appdirs==1.2.0
crayons== 0.1.0
GitPython==2.0.0
giturlparse==0.9.1
2 changes: 1 addition & 1 deletion moban/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.4.0"
__version__ = "0.4.1"
__author__ = "C. W."
5 changes: 5 additions & 0 deletions moban/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
LABEL_SOURCE = "source"
LABEL_DEST = "destination"
LABEL_FORCE_TEMPLATE_TYPE = "force_template_type"
LABEL_TEMPLATE_TYPES = "template_types"

# error messages
ERROR_DATA_FILE_NOT_FOUND = "Both %s and %s does not exist"
Expand Down Expand Up @@ -98,6 +99,10 @@
PYPI_PACKAGE_NAME = "name"
REQUIRE_TYPE = "type"

# Template types
TEMPLATE_TYPES_BASE_TYPE = "base_type"
TEMPLATE_TYPES_OPTIONS = "options"
TEMPLATE_TYPES_FILE_EXTENSIONS = "file_extensions"

# Extension
JINJA_FILTER_EXTENSION = "jinja_filter"
Expand Down
15 changes: 10 additions & 5 deletions moban/jinja2/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self):
constants.TEMPLATE_ENGINE_EXTENSION, tags=["jinja2", "jinja", "jj2", "j2"]
)
class Engine(object):
def __init__(self, template_dirs, extensions=None):
def __init__(self, template_dirs, options=None):
"""
Contruct a jinja2 template engine
Expand All @@ -73,10 +73,15 @@ def __init__(self, template_dirs, extensions=None):
extension for extension in JINJA2_THIRD_PARTY_EXTENSIONS
], # get a copy of this global variable
)
if is_extension_list_valid(extensions):
# because it is modified here
env_params["extensions"] += extensions
import_module_of_extension(extensions)
if options:
if "extensions" in options:
extensions = options.pop("extensions")
if is_extension_list_valid(extensions):
# because it is modified here
env_params["extensions"] += extensions
import_module_of_extension(extensions)

env_params.update(options)
self.jj2_environment = Environment(**env_params)
for filter_name, filter_function in FILTERS.get_all():
self.jj2_environment.filters[filter_name] = filter_function
Expand Down
6 changes: 6 additions & 0 deletions moban/mobanfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ def handle_moban_file_v1(moban_file_configurations, command_line_options):
if extensions:
plugins.ENGINES.register_extensions(extensions)

template_types = merged_options.get(
constants.LABEL_TEMPLATE_TYPES
)
if template_types:
plugins.ENGINES.register_options(template_types)

if targets:
if target:
targets = target
Expand Down
4 changes: 2 additions & 2 deletions moban/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from lml.loader import scan_plugins_regex
from moban.plugins.template import TemplateFactory
from moban.plugins.template import MobanFactory
from moban import constants


Expand All @@ -11,7 +11,7 @@
]


ENGINES = TemplateFactory()
ENGINES = MobanFactory()


def make_sure_all_pkg_are_loaded():
Expand Down
Loading

0 comments on commit 217608f

Please sign in to comment.