From 3a0c3ccd9c022340b63334c543f8ac057931225e Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sun, 16 Aug 2020 20:24:34 +0900 Subject: [PATCH 1/4] Update docs --- docs/pages/examples/style/index.rst | 5 +++++ docs/pages/examples/style/theme.txt | 25 ++++++++++++++++++++++++ docs/pages/introduction/installation.rst | 2 ++ 3 files changed, 32 insertions(+) create mode 100644 docs/pages/examples/style/theme.txt diff --git a/docs/pages/examples/style/index.rst b/docs/pages/examples/style/index.rst index 8d9f3c28..dc3afa88 100644 --- a/docs/pages/examples/style/index.rst +++ b/docs/pages/examples/style/index.rst @@ -4,3 +4,8 @@ Specify Cell Styles For Each Column ================================================================ .. include:: column_style_example.txt + + +Specify theme +================================================================ +.. include:: theme.txt diff --git a/docs/pages/examples/style/theme.txt b/docs/pages/examples/style/theme.txt new file mode 100644 index 00000000..0b873626 --- /dev/null +++ b/docs/pages/examples/style/theme.txt @@ -0,0 +1,25 @@ +``set_theme`` method can set predefined style filters. +The following command will install themes: + +:: + + pip install pytablewriter[theme] + +``altrow`` theme will colored rows alternatively: + +:Sample Code: + .. code-block:: python + + writer = TableWriterFactory.create_from_format_name("md") + writer.headers = ["INT", "STR"] + writer.value_matrix = [[1, "hoge"], [2, "foo"], [3, "bar"]] + writer.margin = 1 + + writer.set_theme("altrow") + + writer.write_table() + +:Output: + .. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter-altrow-theme@master/ss/ptw-altrow-theme_example_default.png + :scale: 100% + :alt: https://github.com/thombashi/pytablewriter-altrow-theme/blob/master/ss/ptw-altrow-theme_example_default.png diff --git a/docs/pages/introduction/installation.rst b/docs/pages/introduction/installation.rst index 649268f7..afadd96c 100644 --- a/docs/pages/introduction/installation.rst +++ b/docs/pages/introduction/installation.rst @@ -52,6 +52,8 @@ Optional dependencies - `dominate `__ - ``sqlite`` extras - `SimpleSQLite `__ +- ``theme`` extras + - `pytablewriter-altrow-theme `__ - ``toml`` extras - `toml `__ From 3fc65670158b408d8704ac4f59e088e8ce85bbf7 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sun, 16 Aug 2020 20:25:47 +0900 Subject: [PATCH 2/4] Add theme extras --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 4826f4a4..8c38446e 100644 --- a/setup.py +++ b/setup.py @@ -52,6 +52,7 @@ def get_release_command_class() -> Dict[str, setuptools.Command]: html_requires = ["dominate>=2.1.5,<3"] logging_requires = ["loguru>=0.4.1,<1"] sqlite_requires = ["SimpleSQLite>=1.1.3,<2"] +theme_requires = ["pytablewriter-altrow-theme>=0.0.1,<1"] toml_requires = ["toml>=0.9.3,<1"] yaml_requires = ["PyYAML>=3.11,<6"] optional_requires = ["simplejson>=3.8.1,<4"] @@ -62,6 +63,7 @@ def get_release_command_class() -> Dict[str, setuptools.Command]: + html_requires + logging_requires + sqlite_requires + + theme_requires + toml_requires + yaml_requires + optional_requires @@ -118,6 +120,7 @@ def get_release_command_class() -> Dict[str, setuptools.Command]: "logging": logging_requires, "sqlite": sqlite_requires, "test": tests_requires, + "theme": theme_requires, "toml": toml_requires, "yaml": yaml_requires, }, From 667ce72d29ea14a89bc0f0c588c7294027dab506 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sun, 16 Aug 2020 20:27:44 +0900 Subject: [PATCH 3/4] Update README --- README.rst | 30 ++++++++++++++++++++++++++---- docs/make_readme.py | 11 +---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index 7aa4e822..8e265942 100644 --- a/README.rst +++ b/README.rst @@ -561,11 +561,31 @@ You can also set ``Style`` to a specific column with index or header by using `` Style filter ~~~~~~~~~~~~~~ -Example: +``set_theme`` method can set predefined style filters. +The following command will install themes: -.. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter@master/ss/color_filter.png - :scale: 60% - :alt: https://github.com/thombashi/pytablewriter/blob/master/ss/color_filter.png +:: + + pip install pytablewriter[theme] + +``altrow`` theme will colored rows alternatively: + +:Sample Code: + .. code-block:: python + + writer = TableWriterFactory.create_from_format_name("md") + writer.headers = ["INT", "STR"] + writer.value_matrix = [[1, "hoge"], [2, "foo"], [3, "bar"]] + writer.margin = 1 + + writer.set_theme("altrow") + + writer.write_table() + +:Output: + .. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter-altrow-theme@master/ss/ptw-altrow-theme_example_default.png + :scale: 100% + :alt: https://github.com/thombashi/pytablewriter-altrow-theme/blob/master/ss/ptw-altrow-theme_example_default.png Make tables for specific applications --------------------------------------- @@ -693,6 +713,8 @@ Optional dependencies - `dominate `__ - ``sqlite`` extras - `SimpleSQLite `__ +- ``theme`` extras + - `pytablewriter-altrow-theme `__ - ``toml`` extras - `toml `__ diff --git a/docs/make_readme.py b/docs/make_readme.py index 1032786c..f5cafe6f 100644 --- a/docs/make_readme.py +++ b/docs/make_readme.py @@ -71,16 +71,7 @@ def write_examples(maker: ReadmeMaker) -> None: maker.write_file(examples_root.joinpath("style", "column_style_example.txt")) maker.write_chapter("Style filter") - maker.write_lines( - [ - "Example:", - "", - ".. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter@master/ss/color_filter.png", - " :scale: 60%", - " :alt: https://github.com/thombashi/pytablewriter/blob/master/ss/color_filter.png", - - ] - ) + maker.write_file(examples_root.joinpath("style", "theme.txt")) maker.set_indent_level(1) maker.write_chapter("Make tables for specific applications") From ee75281cd46c87b302dd37439ef51aa1e2a98f05 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sun, 16 Aug 2020 20:28:10 +0900 Subject: [PATCH 4/4] Bump version --- pytablewriter/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytablewriter/__version__.py b/pytablewriter/__version__.py index bc212020..356ea181 100644 --- a/pytablewriter/__version__.py +++ b/pytablewriter/__version__.py @@ -1,6 +1,6 @@ __author__ = "Tsuyoshi Hombashi" __copyright__ = "Copyright 2016, {}".format(__author__) __license__ = "MIT License" -__version__ = "0.56.0" +__version__ = "0.56.1" __maintainer__ = __author__ __email__ = "tsuyoshi.hombashi@gmail.com"