mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
docs: refactor serve-docs
; add nix run .#docs
Refactor `serve-docs` using `makeWrapper`, make it available as a `serve-docs` package and as the `docs` "app". This means `nix build .#docs` will build the docs while `nix run .#docs` will run the server.
This commit is contained in:
parent
5c49988a7c
commit
f3342bdbd4
5 changed files with 28 additions and 8 deletions
|
@ -101,14 +101,7 @@
|
|||
help = "Build and serve documentation locally";
|
||||
command = ''
|
||||
echo -e "=> Building nixvim documentation...\n"
|
||||
|
||||
doc_derivation=$(${nix} build .#docs --no-link --print-out-paths)
|
||||
|
||||
echo -e "\n=> Documentation successfully built ('$doc_derivation')"
|
||||
|
||||
echo -e "\n=> You can then open your browser to view the doc\n"
|
||||
|
||||
(cd "$doc_derivation"/share/doc && ${pkgs.lib.getExe pkgs.python3} ${./server.py})
|
||||
nix run .#docs
|
||||
'';
|
||||
}
|
||||
{
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
import http.server
|
||||
|
||||
PORT = 8000
|
||||
|
||||
|
||||
class UncachedHTTPHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def end_headers(self):
|
||||
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
self.send_header("Pragma", "no-cache")
|
||||
self.send_header("Expires", "0")
|
||||
super().end_headers()
|
||||
|
||||
|
||||
with http.server.HTTPServer(("", PORT), UncachedHTTPHandler) as httpd:
|
||||
print(f"Serving documentation at http://localhost:{PORT}")
|
||||
httpd.serve_forever()
|
|
@ -7,11 +7,15 @@
|
|||
{
|
||||
perSystem =
|
||||
{
|
||||
config,
|
||||
inputs',
|
||||
system,
|
||||
...
|
||||
}:
|
||||
{
|
||||
# Run the docs server when using `nix run .#docs`
|
||||
apps.docs.program = config.packages.serve-docs;
|
||||
|
||||
packages = import ../docs {
|
||||
nixvim = self;
|
||||
inherit helpers;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue