Move docs build to builddefs.
@ -42,7 +42,7 @@ const config = {
|
|||||||
"@docusaurus/plugin-content-docs",
|
"@docusaurus/plugin-content-docs",
|
||||||
{
|
{
|
||||||
sidebarPath: require.resolve("./sidebars.js"),
|
sidebarPath: require.resolve("./sidebars.js"),
|
||||||
path: ".",
|
path: "../../docs",
|
||||||
routeBasePath: "/",
|
routeBasePath: "/",
|
||||||
exclude: [
|
exclude: [
|
||||||
"node_modules",
|
"node_modules",
|
@ -4,12 +4,12 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"docusaurus": "docusaurus",
|
"docusaurus": "docusaurus",
|
||||||
"start": "docusaurus start",
|
"start": "docusaurus start --host 0.0.0.0 --port 8936",
|
||||||
"build": "docusaurus build",
|
"build": "docusaurus build",
|
||||||
"swizzle": "docusaurus swizzle",
|
"swizzle": "docusaurus swizzle",
|
||||||
"deploy": "docusaurus deploy",
|
"deploy": "docusaurus deploy",
|
||||||
"clear": "docusaurus clear",
|
"clear": "docusaurus clear",
|
||||||
"serve": "docusaurus serve",
|
"serve": "docusaurus serve --host 0.0.0.0 --port 8936",
|
||||||
"write-translations": "docusaurus write-translations",
|
"write-translations": "docusaurus write-translations",
|
||||||
"write-heading-ids": "docusaurus write-heading-ids"
|
"write-heading-ids": "docusaurus write-heading-ids"
|
||||||
},
|
},
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 793 B After Width: | Height: | Size: 793 B |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
@ -1,44 +1,13 @@
|
|||||||
"""Serve QMK documentation locally
|
"""Serve QMK documentation locally
|
||||||
"""
|
"""
|
||||||
import http.server
|
from qmk.docs import prepare_docs_build_area, run_docs_command
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import webbrowser
|
|
||||||
|
|
||||||
from milc import cli
|
from milc import cli
|
||||||
|
|
||||||
|
|
||||||
@cli.argument('-p', '--port', default=8936, type=int, help='Port number to use.')
|
|
||||||
@cli.argument('-b', '--browser', action='store_true', help='Open the docs in the default browser.')
|
|
||||||
@cli.subcommand('Run a local webserver for QMK documentation.', hidden=False if cli.config.user.developer else True)
|
@cli.subcommand('Run a local webserver for QMK documentation.', hidden=False if cli.config.user.developer else True)
|
||||||
def docs(cli):
|
def docs(cli):
|
||||||
"""Spin up a local HTTP server for the QMK docs.
|
"""Spin up a local HTTP server for the QMK docs.
|
||||||
"""
|
"""
|
||||||
os.chdir('docs')
|
prepare_docs_build_area()
|
||||||
|
run_docs_command('start', False)
|
||||||
# If docsify-cli is installed, run that instead so we get live reload
|
|
||||||
if shutil.which('docsify'):
|
|
||||||
command = ['docsify', 'serve', '--port', f'{cli.config.docs.port}', '--open' if cli.config.docs.browser else '']
|
|
||||||
|
|
||||||
cli.log.info(f"Running {{fg_cyan}}{str.join(' ', command)}{{fg_reset}}")
|
|
||||||
cli.log.info("Press Control+C to exit.")
|
|
||||||
|
|
||||||
try:
|
|
||||||
cli.run(command, capture_output=False)
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
cli.log.info("Stopping HTTP server...")
|
|
||||||
else:
|
|
||||||
# Fall back to Python HTTPServer
|
|
||||||
with http.server.HTTPServer(('', cli.config.docs.port), http.server.SimpleHTTPRequestHandler) as httpd:
|
|
||||||
cli.log.info(f"Serving QMK docs at http://localhost:{cli.config.docs.port}/")
|
|
||||||
cli.log.info("Press Control+C to exit.")
|
|
||||||
|
|
||||||
if cli.config.docs.browser:
|
|
||||||
webbrowser.open(f'http://localhost:{cli.config.docs.port}')
|
|
||||||
|
|
||||||
try:
|
|
||||||
httpd.serve_forever()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
cli.log.info("Stopping HTTP server...")
|
|
||||||
finally:
|
|
||||||
httpd.shutdown()
|
|
||||||
|
@ -1,18 +1,10 @@
|
|||||||
"""Build QMK documentation locally
|
"""Build QMK documentation locally
|
||||||
"""
|
"""
|
||||||
import shutil
|
from qmk.docs import prepare_docs_build_area, run_docs_command, BUILD_DOCS_PATH
|
||||||
from pathlib import Path
|
|
||||||
from subprocess import DEVNULL
|
|
||||||
|
|
||||||
from milc import cli
|
from milc import cli
|
||||||
|
|
||||||
DOCS_PATH = Path('docs/')
|
@cli.argument('-s', '--serve', arg_only=True, action='store_true', help="Serves the generated docs once built.")
|
||||||
BUILD_PATH = Path('.build/')
|
|
||||||
BUILD_DOCS_PATH = BUILD_PATH / 'docs'
|
|
||||||
DOXYGEN_PATH = BUILD_DOCS_PATH / 'static' / 'doxygen'
|
|
||||||
# MOXYGEN_PATH = BUILD_DOCS_PATH / 'internals'
|
|
||||||
|
|
||||||
|
|
||||||
@cli.subcommand('Build QMK documentation.', hidden=False if cli.config.user.developer else True)
|
@cli.subcommand('Build QMK documentation.', hidden=False if cli.config.user.developer else True)
|
||||||
def generate_docs(cli):
|
def generate_docs(cli):
|
||||||
"""Invoke the docs generation process
|
"""Invoke the docs generation process
|
||||||
@ -21,30 +13,11 @@ def generate_docs(cli):
|
|||||||
* [ ] Add a real build step... something static docs
|
* [ ] Add a real build step... something static docs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if BUILD_DOCS_PATH.exists():
|
prepare_docs_build_area()
|
||||||
shutil.rmtree(BUILD_DOCS_PATH)
|
|
||||||
if DOXYGEN_PATH.exists():
|
|
||||||
shutil.rmtree(DOXYGEN_PATH)
|
|
||||||
|
|
||||||
cli.log.info('Copying %s folder to %s', DOCS_PATH, BUILD_DOCS_PATH)
|
|
||||||
# ignore .gitignore'd folders when we're testing locally
|
|
||||||
shutil.copytree(DOCS_PATH, BUILD_DOCS_PATH, ignore=shutil.ignore_patterns("node_modules", "build", ".docusaurus"))
|
|
||||||
|
|
||||||
# When not verbose we want to hide all output
|
|
||||||
args = {
|
|
||||||
'capture_output': False if cli.config.general.verbose else True,
|
|
||||||
'check': True,
|
|
||||||
'stdin': DEVNULL,
|
|
||||||
}
|
|
||||||
|
|
||||||
cli.log.info('Generating doxygen docs at %s', DOXYGEN_PATH)
|
|
||||||
cli.run(['doxygen', 'Doxyfile'], **args)
|
|
||||||
# cli.run(['moxygen', '-q', '-g', '-o', MOXYGEN_PATH / '%s.md', DOXYGEN_PATH / 'xml'], **args)
|
|
||||||
|
|
||||||
cli.log.info('Installing docusaurus dependencies')
|
|
||||||
cli.run(['npm', 'ci', '--prefix', BUILD_DOCS_PATH], **args)
|
|
||||||
|
|
||||||
cli.log.info('Building docusarus docs')
|
|
||||||
cli.run(['npm', 'run', '--prefix', BUILD_DOCS_PATH, 'build'], **args)
|
|
||||||
|
|
||||||
|
cli.log.info('Building docusaurus docs')
|
||||||
|
run_docs_command('build')
|
||||||
cli.log.info('Successfully generated docs to %s.', BUILD_DOCS_PATH)
|
cli.log.info('Successfully generated docs to %s.', BUILD_DOCS_PATH)
|
||||||
|
|
||||||
|
if cli.args.serve:
|
||||||
|
run_docs_command('serve', False)
|
||||||
|