Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release 0.4.1 #241

Merged
merged 10 commits into from
Feb 28, 2019
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
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: [email protected]
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