diff --git a/docs/conf.py b/docs/conf.py index 5423f3c..9cc0764 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,7 @@ project = "djlint" copyright = "2021, Riverside Healthcare" author = "Christopher Pickering" -release = "0.4.3" +release = "0.4.4" version = release # -- General configuration --------------------------------------------------- diff --git a/docs/djlint/changelog.rst b/docs/djlint/changelog.rst index f1cc04c..2d570ed 100644 --- a/docs/djlint/changelog.rst +++ b/docs/djlint/changelog.rst @@ -1,6 +1,10 @@ Changelog ========= +0.4.4 +----- +- Change indent config from string to int. ``--indent 3`` + 0.4.3 ----- - Added cli option for indent spacing. ``--indent=" "`` diff --git a/docs/djlint/configuration.rst b/docs/djlint/configuration.rst index 47efa05..ccf9ffd 100644 --- a/docs/djlint/configuration.rst +++ b/docs/djlint/configuration.rst @@ -44,13 +44,13 @@ Usage: indent ------ -Use to change the code indentation. Default is four spaces. +Use to change the code indentation. Default is 4 (four spaces). Usage: .. code:: toml - indent = " " # change indentation level + indent = 3 # change indentation level exclude ------- diff --git a/docs/djlint/usage.rst b/docs/djlint/usage.rst index c0829d1..1616737 100644 --- a/docs/djlint/usage.rst +++ b/docs/djlint/usage.rst @@ -58,7 +58,7 @@ CLI Args Options: -e, --extension TEXT File extension to lint [default: html] -i, --ignore "Codes" Rules to be ignored. ex: "W013,W014" - --indent Indent spacing. + --indent Indent spacing. ex: 3 --reformat Reformat the file(s). --check Check formatting on the file(s). --quiet Do not print diff when reformatting. diff --git a/pyproject.toml b/pyproject.toml index 460d4e0..370d89f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name="djlint" -version="0.4.3" +version="0.4.4" description="HTML Template Linter and Formatter" license="GPL-3.0-or-later" authors=["Christopher Pickering "] diff --git a/src/djlint/__init__.py b/src/djlint/__init__.py index 8567c0a..d4bd991 100644 --- a/src/djlint/__init__.py +++ b/src/djlint/__init__.py @@ -186,8 +186,8 @@ def build_quantity_tense(size: int) -> str: ) @click.option( "--indent", - type=str, - help="Indent spacing.", + type=int, + help="Indent spacing. ex: 3", ) @click.option( "--quiet", @@ -199,7 +199,7 @@ def main( extension: str, ignore: str, reformat: bool, - indent: Optional[str], + indent: Optional[int], check: bool, quiet: bool, ) -> None: diff --git a/src/djlint/settings.py b/src/djlint/settings.py index d27daea..340e6af 100644 --- a/src/djlint/settings.py +++ b/src/djlint/settings.py @@ -59,7 +59,7 @@ class Config: src: str, ignore: Optional[str] = None, extension: Optional[str] = None, - indent: Optional[str] = None, + indent: Optional[int] = None, quiet: Optional[bool] = False, ): @@ -74,7 +74,7 @@ class Config: ) # base options - self.indent: str = str(indent or djlint_settings.get("indent", " ")) + self.indent: str = (indent or int(djlint_settings.get("indent", 4))) * " " print(len(self.indent)) default_exclude: str = r""" diff --git a/tests/config_indent/pyproject.toml b/tests/config_indent/pyproject.toml index ca52acd..5fcedd8 100644 --- a/tests/config_indent/pyproject.toml +++ b/tests/config_indent/pyproject.toml @@ -1,3 +1,3 @@ [tool] [tool.djlint] -indent = " " +indent = 2 diff --git a/tests/test_config.py b/tests/test_config.py index 5c0afcc..cdd2ada 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -64,9 +64,7 @@ def test_indent(runner: CliRunner) -> None: ) assert result.exit_code == 1 - result = runner.invoke( - djlint, ["tests/config_indent", "--check", "--indent", " "] - ) + result = runner.invoke(djlint, ["tests/config_indent", "--check", "--indent", 3]) assert ( """-