Merge pull request #241266 from aldoborrero/feat/mdformat-plugins

Add mdformat plugins
This commit is contained in:
Jonas Chevalier 2023-07-03 20:27:18 +02:00 committed by GitHub
commit 507e8b4cca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 541 additions and 40 deletions

View file

@ -632,6 +632,12 @@
githubId = 43479487;
name = "Titouan Biteau";
};
aldoborrero = {
email = "aldoborrero+nixos@pm.me";
github = "aldoborrero";
githubId = 82811;
name = "Aldo Borrero";
};
aleksana = {
email = "me@aleksana.moe";
github = "Aleksanaa";

View file

@ -0,0 +1,52 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, mdformat
, python3
, pythonOlder
}:
let
python = python3.override {
packageOverrides = self: super: {
mdit-py-plugins = super.mdit-py-plugins.overridePythonAttrs (_prev: rec {
version = "0.4.0";
doCheck = false;
src = fetchFromGitHub {
owner = "executablebooks";
repo = "mdit-py-plugins";
rev = "refs/tags/v${version}";
hash = "sha256-YBJu0vIOD747DrJLcqiZMHq34+gHdXeGLCw1OxxzIJ0=";
};
});
};
};
in python.pkgs.buildPythonPackage rec {
pname = "mdformat-admon";
version = "1.0.2";
format = "flit";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "KyleKing";
repo = pname;
rev = "v${version}";
hash = "sha256-33Q3Re/axnoOHZ9XYA32mmK+efsSelJXW8sD7C1M/jU=";
};
buildInputs = with python.pkgs; [
mdformat
];
propagatedBuildInputs = with python.pkgs; [
mdit-py-plugins
];
meta = with lib; {
description = "mdformat plugin for admonitions";
homepage = "https://github.com/KyleKing/mdformat-admon";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero ];
};
}

View file

@ -0,0 +1,46 @@
{ lib
, beautysh
, buildPythonPackage
, fetchFromGitHub
, mdformat
, mdformat-gfm
, mdit-py-plugins
, poetry-core
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-beautysh";
version = "0.1.1";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "hukkin";
repo = pname;
rev = "refs/tags/${version}";
hash = "sha256-mH9PN6QsPmnIzh/0vxa+5mYLzANUHRruXC0ql4h8myw=";
};
nativeBuildInputs = [
poetry-core
];
buildInputs = [
mdformat
mdformat-gfm
mdit-py-plugins
];
propagatedBuildInputs = [
beautysh
];
meta = with lib; {
description = "Mdformat plugin to beautify Bash scripts";
homepage = "https://github.com/hukkin/mdformat-beautysh";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero ];
};
}

View file

@ -0,0 +1,40 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, linkify-it-py
, markdown-it-py
, mdformat
, mdit-py-plugins
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-footnote";
version = "0.1.1";
format = "flit";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "executablebooks";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-DUCBWcmB5i6/HkqxjlU3aTRO7i0n2sj+e/doKB8ffeo=";
};
buildInputs = [
mdformat
mdit-py-plugins
];
pythonImportsCheck = [
"mdformat_footnote"
];
meta = with lib; {
description = "Footnote format addition for mdformat";
homepage = "https://github.com/executablebooks/mdformat-footnote";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero ];
};
}

View file

@ -0,0 +1,45 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, linkify-it-py
, markdown-it-py
, mdformat
, mdit-py-plugins
, ruamel-yaml
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-frontmatter";
version = "2.0.1";
format = "flit";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "butler54";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-PhT5whtvvcYSs5gHQEsIvV1evhx7jR+3DWFMHrF0uMw=";
};
buildInputs = [
mdformat
mdit-py-plugins
];
propagatedBuildInputs = [
ruamel-yaml
];
pythonImportsCheck = [
"mdformat_frontmatter"
];
meta = with lib; {
description = "mdformat plugin to ensure frontmatter is respected";
homepage = "https://github.com/butler54/mdformat-frontmatter";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero polarmutex ];
};
}

View file

@ -0,0 +1,58 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, linkify-it-py
, markdown-it-py
, mdformat
, mdformat-gfm
, mdformat-tables
, mdit-py-plugins
, poetry-core
, pytestCheckHook
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-gfm";
version = "0.3.5";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "hukkin";
repo = pname;
rev = "refs/tags/${version}";
hash = "sha256-7sIa50jCN+M36Y0C05QaAL+TVwLzKxJ0gzpZI1YQFxg=";
};
nativeBuildInputs = [
poetry-core
];
buildInputs = [
mdformat
markdown-it-py
mdit-py-plugins
];
propagatedBuildInputs = [
mdformat-tables
linkify-it-py
];
nativeCheckInputs = [
pytestCheckHook
];
pythonImportsCheck = [
"mdformat_gfm"
];
meta = with lib; {
description = "Mdformat plugin for GitHub Flavored Markdown compatibility";
homepage = "https://github.com/hukkin/mdformat-gfm";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero polarmutex ];
};
}

View file

@ -0,0 +1,40 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, mdformat
, mdformat-gfm
, mdit-py-plugins
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-mkdocs";
version = "1.0.2";
format = "flit";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "KyleKing";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-H+wqgcXNrdrZ5aQvZ7XM8YpBpVZM6pFtsANC00UZ0jM=";
};
buildInputs = [
mdformat
mdformat-gfm
mdit-py-plugins
];
pythonImportsCheck = [
"mdformat_mkdocs"
];
meta = with lib; {
description = "mdformat plugin for MkDocs";
homepage = "https://github.com/KyleKing/mdformat-mkdocs";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero ];
};
}

View file

@ -0,0 +1,41 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, mdformat
, poetry-core
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-nix-alejandra";
version = "0.1.0";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "aldoborrero";
repo = pname;
rev = "${version}";
hash = "sha256-jUXApGsxCA+pRm4m4ZiHWlxmVkqCPx3A46oQdtyKz5g=";
};
nativeBuildInputs = [
poetry-core
];
buildInputs = [
mdformat
];
pythonImportsCheck = [
"mdformat_nix_alejandra"
];
meta = with lib; {
description = "Mdformat plugin format Nix code blocks with alejandra";
homepage = "https://github.com/aldoborrero/mdformat-nix-alejandra";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero ];
};
}

View file

@ -0,0 +1,37 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, mdformat
, mdit-py-plugins
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-simple-breaks";
version = "0.0.1";
format = "flit";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "csala";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-4lJHB4r9lI2uGJ/BmFFc92sumTRKBBwiRmGBdQkzfd0=";
};
buildInputs = [
mdformat
];
pythonImportsCheck = [
"mdformat_simple_breaks"
];
meta = with lib; {
description = "mdformat plugin to render thematic breaks using three dashes";
homepage = "https://github.com/csala/mdformat-simple-breaks";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero ];
};
}

View file

@ -0,0 +1,42 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, mdformat
, mdit-py-plugins
, pytestCheckHook
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-tables";
version = "0.4.1";
format = "flit";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "executablebooks";
repo = pname;
rev = "v${version}";
hash = "sha256-Q61GmaRxjxJh9GjyR8QCZOH0njFUtAWihZ9lFQJ2nQQ=";
};
buildInputs = [
mdformat
];
nativeCheckInputs = [
pytestCheckHook
];
pythonImportsCheck = [
"mdformat_tables"
];
meta = with lib; {
description = "An mdformat plugin for rendering tables";
homepage = "https://github.com/executablebooks/mdformat-tables";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero polarmutex ];
};
}

View file

@ -0,0 +1,47 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, mdformat
, mdit-py-plugins
, poetry-core
, pytestCheckHook
, pythonOlder
}:
buildPythonPackage rec {
pname = "mdformat-toc";
version = "0.3.0";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "hukkin";
repo = pname;
rev = "refs/tags/${version}";
hash = "sha256-3EX6kGez408tEYiR9VSvi3GTrb4ds+HJwpFflv77nkg=";
};
nativeBuildInputs = [
poetry-core
];
buildInputs = [
mdformat
];
nativeCheckInputs = [
pytestCheckHook
];
pythonImportsCheck = [
"mdformat_toc"
];
meta = with lib; {
description = "Mdformat plugin to generate a table of contents";
homepage = "https://github.com/hukkin/mdformat-toc";
license = licenses.mit;
maintainers = with maintainers; [ aldoborrero polarmutex ];
};
}

View file

@ -1,63 +1,100 @@
{ lib
, buildPythonApplication
, buildPythonPackage
, fetchFromGitHub
, importlib-metadata
, makeWrapper
, markdown-it-py
, poetry-core
, pytestCheckHook
, python3
, pythonOlder
, setuptools
, tomli
, typing-extensions
}:
buildPythonPackage rec {
pname = "mdformat";
version = "0.7.16";
format = "pyproject";
let
withPlugins = plugins: buildPythonApplication {
pname = "${package.pname}";
inherit (package) version;
format = "other";
disabled = pythonOlder "3.7";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "executablebooks";
repo = pname;
rev = version;
hash = "sha256-6MWUkvZp5CYUWsbMGXM2gudjn5075j5FIuaNnCrgRNs=";
dontUnpack = true;
dontBuild = true;
doCheck = false;
nativeBuildInputs = [
makeWrapper
];
installPhase = ''
makeWrapper ${package}/bin/mdformat $out/bin/mdformat \
--prefix PYTHONPATH : "${package}/${python3.sitePackages}:$PYTHONPATH"
ln -sfv ${package}/lib $out/lib
'';
propagatedBuildInputs = package.propagatedBuildInputs ++ plugins;
passthru = package.passthru // {
withPlugins = morePlugins: withPlugins (morePlugins ++ plugins);
};
meta.mainProgram = "mdformat";
};
nativeBuildInputs = [
poetry-core
setuptools
];
package = buildPythonPackage rec {
pname = "mdformat";
version = "0.7.16";
format = "pyproject";
propagatedBuildInputs = [
markdown-it-py
tomli
] ++ lib.optionals (pythonOlder "3.10") [
importlib-metadata
] ++ lib.optionals (pythonOlder "3.7") [
typing-extensions
];
disabled = pythonOlder "3.7";
nativeCheckInputs = [
pytestCheckHook
];
src = fetchFromGitHub {
owner = "executablebooks";
repo = pname;
rev = version;
hash = "sha256-6MWUkvZp5CYUWsbMGXM2gudjn5075j5FIuaNnCrgRNs=";
};
disabledTests = [
# AssertionError
"test_no_codeblock_trailing_newline"
# Issue with upper/lower case
"default_style.md-options0"
];
nativeBuildInputs = [
poetry-core
setuptools
];
pythonImportsCheck = [
"mdformat"
];
propagatedBuildInputs = [
markdown-it-py
tomli
] ++ lib.optionals (pythonOlder "3.10") [
importlib-metadata
] ++ lib.optionals (pythonOlder "3.7") [
typing-extensions
];
meta = with lib; {
description = "CommonMark compliant Markdown formatter";
homepage = "https://mdformat.rtfd.io/";
license = with licenses; [ mit ];
maintainers = with maintainers; [ fab ];
nativeCheckInputs = [
pytestCheckHook
];
disabledTests = [
# AssertionError
"test_no_codeblock_trailing_newline"
# Issue with upper/lower case
"default_style.md-options0"
];
pythonImportsCheck = [
"mdformat"
];
passthru = {inherit withPlugins;};
meta = with lib; {
description = "CommonMark compliant Markdown formatter";
homepage = "https://mdformat.rtfd.io/";
license = with licenses; [ mit ];
maintainers = with maintainers; [ fab aldoborrero ];
};
};
}
in package

View file

@ -6211,6 +6211,16 @@ self: super: with self; {
md2gemini = callPackage ../development/python-modules/md2gemini { };
mdformat = callPackage ../development/python-modules/mdformat { };
mdformat-admon = callPackage ../development/python-modules/mdformat-admon { };
mdformat-beautysh = callPackage ../development/python-modules/mdformat-beautysh { };
mdformat-footnote = callPackage ../development/python-modules/mdformat-footnote { };
mdformat-frontmatter = callPackage ../development/python-modules/mdformat-frontmatter { };
mdformat-gfm = callPackage ../development/python-modules/mdformat-gfm { };
mdformat-mkdocs = callPackage ../development/python-modules/mdformat-mkdocs { };
mdformat-nix-alejandra = callPackage ../development/python-modules/mdformat-nix-alejandra { };
mdformat-simple-breaks = callPackage ../development/python-modules/mdformat-simple-breaks { };
mdformat-tables = callPackage ../development/python-modules/mdformat-tables { };
mdformat-toc = callPackage ../development/python-modules/mdformat-toc { };
mdit-py-plugins = callPackage ../development/python-modules/mdit-py-plugins { };