mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
docs/server: open browser using xdg-open
This commit is contained in:
parent
601d4309ed
commit
1ff5e1a33b
2 changed files with 5 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
runCommand,
|
runCommand,
|
||||||
makeBinaryWrapper,
|
makeBinaryWrapper,
|
||||||
python3,
|
python3,
|
||||||
|
xdg-utils,
|
||||||
docs,
|
docs,
|
||||||
}:
|
}:
|
||||||
runCommand "serve-docs"
|
runCommand "serve-docs"
|
||||||
|
@ -15,5 +16,6 @@ runCommand "serve-docs"
|
||||||
makeWrapper ${lib.getExe python3} \
|
makeWrapper ${lib.getExe python3} \
|
||||||
$out/bin/server \
|
$out/bin/server \
|
||||||
--add-flags ${./server.py} \
|
--add-flags ${./server.py} \
|
||||||
--chdir ${docs}
|
--chdir ${docs} \
|
||||||
|
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]}
|
||||||
''
|
''
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||||
|
from subprocess import call
|
||||||
|
|
||||||
PORT = 8000
|
PORT = 8000
|
||||||
URL = f"http://localhost:{PORT}"
|
URL = f"http://localhost:{PORT}"
|
||||||
|
@ -8,6 +9,7 @@ class AutoBrowseHTTPServer(HTTPServer):
|
||||||
def server_activate(self):
|
def server_activate(self):
|
||||||
HTTPServer.server_activate(self)
|
HTTPServer.server_activate(self)
|
||||||
print(f"Serving documentation at {URL}")
|
print(f"Serving documentation at {URL}")
|
||||||
|
call(["xdg-open", URL])
|
||||||
|
|
||||||
|
|
||||||
class UncachedHTTPHandler(SimpleHTTPRequestHandler):
|
class UncachedHTTPHandler(SimpleHTTPRequestHandler):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue