diff --git a/pkgs/development/python-modules/mkdocs-macros/default.nix b/pkgs/development/python-modules/mkdocs-macros/default.nix new file mode 100644 index 000000000000..54a06d7d0bf9 --- /dev/null +++ b/pkgs/development/python-modules/mkdocs-macros/default.nix @@ -0,0 +1,43 @@ +{ lib +, callPackage +, buildPythonPackage +, fetchPypi +, mkdocs +, mkdocs-macros +, mkdocs-material +, jinja2 +, dateutil +, termcolor +, pyyaml +, runCommand +, setuptools +}: + +buildPythonPackage rec { + pname = "mkdocs-macros-plugin"; + version = "0.7.0"; + + src = fetchPypi { + inherit pname version; + sha256 = "sha256:0206cm0153vzp10c8a15bi2znisq5pv59zi9vrcm74pnpk5f2r4y"; + }; + + propagatedBuildInputs = [ + jinja2 + dateutil + termcolor + pyyaml + mkdocs + ]; + + passthru.tests.example-doc = callPackage ./tests.nix { }; + + pythonImportsCheck = [ "mkdocs_macros" ]; + + meta = with lib; { + homepage = "https://github.com/fralau/mkdocs_macros_plugin"; + description = "Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code."; + license = licenses.mit; + maintainers = with maintainers; [ tljuniper ]; + }; +} diff --git a/pkgs/development/python-modules/mkdocs-macros/mkdocs-macros-test.nix b/pkgs/development/python-modules/mkdocs-macros/mkdocs-macros-test.nix new file mode 100644 index 000000000000..8a53933b19af --- /dev/null +++ b/pkgs/development/python-modules/mkdocs-macros/mkdocs-macros-test.nix @@ -0,0 +1,27 @@ +{ lib +, callPackage +, buildPythonPackage +, fetchPypi +, runCommand +, setuptools +}: + +# Is required for properly testing mkdocs-macros +buildPythonPackage rec { + pname = "mkdocs-macros-test"; + version = "0.1.0"; + + src = fetchPypi { + inherit pname version; + sha256 = "sha256:1w12skm8l0r2x6z1va996lvq6z1873d0xzql9n0aja0g0v6s7ay5"; + }; + + pythonImportsCheck = [ "mkdocs_macros_test" ]; + + meta = with lib; { + homepage = "https://github.com/fralau/mkdocs-macros-test"; + description = "Implementation of a (model) pluglet for mkdocs-macros"; + license = licenses.mit; + maintainers = with maintainers; [ tljuniper ]; + }; +} diff --git a/pkgs/development/python-modules/mkdocs-macros/tests.nix b/pkgs/development/python-modules/mkdocs-macros/tests.nix new file mode 100644 index 000000000000..5ddcd26e0dab --- /dev/null +++ b/pkgs/development/python-modules/mkdocs-macros/tests.nix @@ -0,0 +1,49 @@ +{ setuptools +, mkdocs +, mkdocs-macros +, mkdocs-material +, runCommand +, callPackage +}: + +let + inherit (mkdocs-macros) pname version src; + + mkdocs-macros-test = callPackage ./mkdocs-macros-test.nix { }; + + env = { + nativeBuildInputs = [ + setuptools + mkdocs + mkdocs-macros + mkdocs-macros-test + mkdocs-material + ]; + }; +in +runCommand "mkdocs-macros-example-docs" env '' + set -euo pipefail + mkdir $out + + base_dir=${pname}-${version}/test + tar --extract "--file=${src}" + + for test_dir in $base_dir/*/; do + pushd $test_dir + mkdocs build --site-dir=$out/$test_dir + popd + done + + # Do some static checks on the generated content + pushd $out/$base_dir + # Non-existent variables + cat debug/index.html | grep "another one: that" + # File inclusion + cat module/index.html | grep "part from an included file!" + # Variable replacement + cat module_dir/index.html | grep "total costs is 50 euros" + # New syntax with square brackets + cat new_syntax/index.html | grep "expensive" + # General info on macros + cat simple/index.html | grep "Macros Plugin Environment" +'' diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 2f9ed57a88ca..4557d81cf53a 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5338,6 +5338,7 @@ in { mkdocs = callPackage ../development/python-modules/mkdocs { }; mkdocs-drawio-exporter = callPackage ../development/python-modules/mkdocs-drawio-exporter { }; + mkdocs-macros = callPackage ../development/python-modules/mkdocs-macros { }; mkdocs-material = callPackage ../development/python-modules/mkdocs-material { }; mkdocs-material-extensions = callPackage ../development/python-modules/mkdocs-material/mkdocs-material-extensions.nix { }; mkdocs-minify = callPackage ../development/python-modules/mkdocs-minify { };