diff options
author | Jacek Galowicz <jacek@galowicz.de> | 2022-05-25 13:22:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-25 13:22:31 +0200 |
commit | f16159714ced92da3d553fa564d7438de226020e (patch) | |
tree | b8ae9150832b85145fbf6321628ab9706b1c3e9f /pkgs/development | |
parent | fd5aea3c09ade960d6f3c32b6a49d5081bc4308b (diff) | |
parent | f3b7a7d6540bb5700d58672f268411fa5ea5509c (diff) |
Merge pull request #173267 from tljuniper/add-mkdocs-macros-plugin
python3Packages.mkdocs-macros: init at 0.7.0
Diffstat (limited to 'pkgs/development')
3 files changed, 119 insertions, 0 deletions
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 <em>included</em> 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" +'' |