add hot reload feature

This commit is contained in:
hoangvv 2025-02-25 11:05:33 +07:00
parent a94d72c241
commit 181c51c9ed
4 changed files with 24 additions and 3 deletions

View File

@ -14,6 +14,7 @@ ifndef CURRENT_LANG
endif endif
SPHINX_BUILD = sphinx-build SPHINX_BUILD = sphinx-build
SPHINX_AUTO_BUILD = sphinx-autobuild
CONFIG_DIR = . CONFIG_DIR = .
SPHINXOPTS = -D project_root=$(ROOT) -D canonical_version=$(CANONICAL_VERSION) \ SPHINXOPTS = -D project_root=$(ROOT) -D canonical_version=$(CANONICAL_VERSION) \
-D versions=$(VERSIONS) -D languages=$(LANGUAGES) -D language=$(CURRENT_LANG) \ -D versions=$(VERSIONS) -D languages=$(LANGUAGES) -D language=$(CURRENT_LANG) \
@ -24,7 +25,14 @@ SPHINXOPTS = -D project_root=$(ROOT) -D canonical_version=$(CANONICAL_VERSIO
-A plausible_domain=$(PLAUSIBLE_DOMAIN) \ -A plausible_domain=$(PLAUSIBLE_DOMAIN) \
-j $(WORKERS) -j $(WORKERS)
SOURCE_DIR = content SOURCE_DIR = content
THEME = extensions/odoo_theme
SERVER_IP := $(shell ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
# Get all listening ports
LISTENING_PORTS := $(shell ss -tuln | awk 'NR>1 {print $$4}' | awk -F: '{print $$NF}' | sort -n | uniq)
# Default port
OPEN_PORTS := $(shell ss -tuln | awk 'NR>1 {print $$4}' | awk -F: '{print $$NF}' | sort -n | uniq)
SELECTED_PORT := $(shell echo "$(OPEN_PORTS)" | awk 'NR==1')
HTML_BUILD_DIR = $(BUILD_DIR)/html HTML_BUILD_DIR = $(BUILD_DIR)/html
ifdef VERSIONS ifdef VERSIONS
HTML_BUILD_DIR := $(HTML_BUILD_DIR)/18.0 HTML_BUILD_DIR := $(HTML_BUILD_DIR)/18.0
@ -55,6 +63,10 @@ html: $(HTML_BUILD_DIR)/_static/style.css
$(SPHINX_BUILD) -c $(CONFIG_DIR) -b html $(SPHINXOPTS) $(SOURCE_DIR) $(HTML_BUILD_DIR) $(SPHINX_BUILD) -c $(CONFIG_DIR) -b html $(SPHINXOPTS) $(SOURCE_DIR) $(HTML_BUILD_DIR)
@echo "Build finished." @echo "Build finished."
livehtml: SPHINXOPTS += -A collapse_menu=True
livehtml: $(HTML_BUILD_DIR)/_static/style.css
@echo "Starting Live Server..."
$(SPHINX_AUTO_BUILD) $(SOURCE_DIR) $(HTML_BUILD_DIR) --port=8000 --host=0.0.0.0 --watch $(THEME) $(SPHINXOPTS) -c $(CONFIG_DIR) -b html
# To call *after* `make html` # To call *after* `make html`
# Binary dependencies (Debian): texlive-fonts-recommended texlive-latex-extra # Binary dependencies (Debian): texlive-fonts-recommended texlive-latex-extra
# texlive-fonts-extra # texlive-fonts-extra

11
conf.py
View File

@ -46,7 +46,10 @@ needs_sphinx = '3.0.0'
language = None language = None
# The suffix of source filenames. # The suffix of source filenames.
source_suffix = '.rst' source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = 'index'
@ -65,7 +68,7 @@ exclude_patterns = [
# See https://docutils.sourceforge.io/docs/ref/rst/roles.html#standard-roles for other roles. # See https://docutils.sourceforge.io/docs/ref/rst/roles.html#standard-roles for other roles.
default_role = 'literal' default_role = 'literal'
html_copy_source = False
# Whether scaled down images should be be wrapped in a `<a/>` tag linking to the image file or not. # Whether scaled down images should be be wrapped in a `<a/>` tag linking to the image file or not.
html_scaled_image_link = False html_scaled_image_link = False
@ -191,6 +194,8 @@ extensions = [
# Strange html domain logic used in memento pages # Strange html domain logic used in memento pages
'html_domain', 'html_domain',
'myst_parser',
] ]
if odoo_dir_in_path: if odoo_dir_in_path:
@ -497,6 +502,8 @@ def _generate_alternate_urls(app, pagename, templatename, context, doctree):
def _build_url(_version=None, _lang=None): def _build_url(_version=None, _lang=None):
# print(f"###################################{app.config.is_remote_build}")
# print(f"###################################{app.config.project_root}")
if app.config.is_remote_build: if app.config.is_remote_build:
# Project root like https://www.odoo.com/documentation # Project root like https://www.odoo.com/documentation
_root = app.config.project_root _root = app.config.project_root

View File

@ -7,7 +7,7 @@
</div> </div>
<div class="d-flex flex-grow-1"> <div class="d-flex flex-grow-1">
{%- include "layout_templates/searchbox.html" %} {%- include "layout_templates/searchbox.html" %}
<a class="btn btn-primary fw_bold ms-auto d-none d-lg-inline-block" href="https://odoo.com/trial">{{ _('Try Odoo for FREE') }}</a> <a class="btn btn-primary fw_bold ms-auto d-none d-lg-inline-block" href="https://erp.nzvps.com/lien-he">{{ _('Contact Us') }}</a>
</div> </div>
</div> </div>
<div class="o_subheader border-bottom d-flex"> <div class="o_subheader border-bottom d-flex">

View File

@ -9,3 +9,5 @@ sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-serializinghtml==1.1.5 sphinxcontrib-serializinghtml==1.1.5
sphinxcontrib-qthelp==1.0.3 sphinxcontrib-qthelp==1.0.3
sphinx-tabs==3.4.5 # Compatibility with docutils==0.17.0 sphinx-tabs==3.4.5 # Compatibility with docutils==0.17.0
myst-parser==0.15.2
sphinx-autobuild