From 181c51c9ed8d0a1c1039497e6489ed3bc1a1dd5e Mon Sep 17 00:00:00 2001 From: hoangvv Date: Tue, 25 Feb 2025 11:05:33 +0700 Subject: [PATCH] add hot reload feature --- Makefile | 12 ++++++++++++ conf.py | 11 +++++++++-- extensions/odoo_theme/layout_templates/header.html | 2 +- requirements.txt | 2 ++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 79e87a18e..e1b0bbae8 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ ifndef CURRENT_LANG endif SPHINX_BUILD = sphinx-build +SPHINX_AUTO_BUILD = sphinx-autobuild CONFIG_DIR = . SPHINXOPTS = -D project_root=$(ROOT) -D canonical_version=$(CANONICAL_VERSION) \ -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) \ -j $(WORKERS) 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 ifdef VERSIONS 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) @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` # Binary dependencies (Debian): texlive-fonts-recommended texlive-latex-extra # texlive-fonts-extra diff --git a/conf.py b/conf.py index ed999800d..604dc3a82 100644 --- a/conf.py +++ b/conf.py @@ -46,7 +46,10 @@ needs_sphinx = '3.0.0' language = None # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = { + '.rst': 'restructuredtext', + '.md': 'markdown', +} # The master toctree document. master_doc = 'index' @@ -65,7 +68,7 @@ exclude_patterns = [ # See https://docutils.sourceforge.io/docs/ref/rst/roles.html#standard-roles for other roles. default_role = 'literal' - +html_copy_source = False # Whether scaled down images should be be wrapped in a `` tag linking to the image file or not. html_scaled_image_link = False @@ -191,6 +194,8 @@ extensions = [ # Strange html domain logic used in memento pages 'html_domain', + + 'myst_parser', ] 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): + # print(f"###################################{app.config.is_remote_build}") + # print(f"###################################{app.config.project_root}") if app.config.is_remote_build: # Project root like https://www.odoo.com/documentation _root = app.config.project_root diff --git a/extensions/odoo_theme/layout_templates/header.html b/extensions/odoo_theme/layout_templates/header.html index f04d9664a..9f5496978 100644 --- a/extensions/odoo_theme/layout_templates/header.html +++ b/extensions/odoo_theme/layout_templates/header.html @@ -7,7 +7,7 @@
{%- include "layout_templates/searchbox.html" %} - {{ _('Try Odoo for FREE') }} + {{ _('Contact Us') }}
diff --git a/requirements.txt b/requirements.txt index ea06b6afa..ba0729599 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,5 @@ sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-serializinghtml==1.1.5 sphinxcontrib-qthelp==1.0.3 sphinx-tabs==3.4.5 # Compatibility with docutils==0.17.0 +myst-parser==0.15.2 +sphinx-autobuild \ No newline at end of file