From 9176f20bc31662d991782a04c339feb2b4ef02a9 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Mon, 2 Mar 2020 00:44:35 +0100 Subject: [PATCH 1/2] httpie: add manpage and html docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit httpie has quite extensive documentation in form of its rst readme. With docutils it’s quite easy to convert to html. We can also convert it to a manpage, which makes the documentation accessible from the command line (even though it’s not quite standard format as far as manpages go; however a lot better than nothing). --- pkgs/tools/networking/httpie/default.nix | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pkgs/tools/networking/httpie/default.nix b/pkgs/tools/networking/httpie/default.nix index 38fdab358c9..b6a7c632930 100644 --- a/pkgs/tools/networking/httpie/default.nix +++ b/pkgs/tools/networking/httpie/default.nix @@ -11,6 +11,8 @@ python3Packages.buildPythonApplication rec { sha256 = "0d0rsn5i973l9y0ws3xmnzaw4jwxdlryyjbasnlddph5mvkf7dq0"; }; + outputs = [ "out" "doc" "man" ]; + propagatedBuildInputs = with python3Packages; [ pygments requests setuptools ]; dontUseSetuptoolsCheck = true; patches = [ ./strip-venv.patch ]; @@ -22,6 +24,54 @@ python3Packages.buildPythonApplication rec { pytestCheckHook ]; + postInstall = '' + mkdir -p $man/share/man/man1 + + docdir=$doc/share/doc/httpie + mkdir -p $docdir/html + + cp AUTHORS.rst CHANGELOG.rst CONTRIBUTING.rst $docdir + + # helpfully, the readme has a `no-web` class to exclude + # the parts that are not relevant for offline docs + + # this one build link was not marked however + sed -e 's/^|build|//g' -i README.rst + + toHtml() { + ${docutils}/bin/rst2html5 \ + --strip-elements-with-class=no-web \ + --title=http \ + --no-generator \ + --no-datestamp \ + --no-source-link \ + "$1" \ + "$2" + } + + toHtml README.rst $docdir/html/index.html + toHtml CHANGELOG.rst $docdir/html/CHANGELOG.html + toHtml CONTRIBUTING.rst $docdir/html/CONTRIBUTING.html + + # change a few links to the local files + substituteInPlace $docdir/html/index.html \ + --replace \ + 'https://github.com/jakubroztocil/httpie/blob/master/CHANGELOG.rst' \ + "CHANGELOG.html" \ + --replace \ + 'https://github.com/jakubroztocil/httpie/blob/master/CONTRIBUTING.rst' \ + "CONTRIBUTING.html" + + ${docutils}/bin/rst2man \ + --strip-elements-with-class=no-web \ + --title=http \ + --no-generator \ + --no-datestamp \ + --no-source-link \ + README.rst \ + $man/share/man/man1/http.1 + ''; + # the tests call rst2pseudoxml.py from docutils preCheck = '' export PATH=${docutils}/bin:$PATH From 2167ed8aac16025303564edac2e9646db1995da7 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Mon, 2 Mar 2020 01:16:54 +0100 Subject: [PATCH 2/2] httpie: add fish and bash completions --- pkgs/tools/networking/httpie/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/tools/networking/httpie/default.nix b/pkgs/tools/networking/httpie/default.nix index b6a7c632930..a0e2b8e01cc 100644 --- a/pkgs/tools/networking/httpie/default.nix +++ b/pkgs/tools/networking/httpie/default.nix @@ -25,6 +25,14 @@ python3Packages.buildPythonApplication rec { ]; postInstall = '' + # install completions + install -Dm555 \ + extras/httpie-completion.bash \ + $out/share/bash-completion/completions/http.bash + install -Dm555 \ + extras/httpie-completion.fish \ + $out/share/fish/vendor_completions.d/http.fish + mkdir -p $man/share/man/man1 docdir=$doc/share/doc/httpie