From 167396142e3a584527bbafadb1a05c10dec0f60c Mon Sep 17 00:00:00 2001 From: Pasha Stetsenko Date: Mon, 28 Mar 2022 02:23:03 -0700 Subject: [PATCH] docs: Take PUBLISH_PATH into account when building docs (#1499) --- doc/_sphinx/extensions/flutter_app.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/_sphinx/extensions/flutter_app.py b/doc/_sphinx/extensions/flutter_app.py index 1b8bc2ef4..09c5b1d47 100644 --- a/doc/_sphinx/extensions/flutter_app.py +++ b/doc/_sphinx/extensions/flutter_app.py @@ -81,7 +81,7 @@ class FlutterAppDirective(SphinxDirective): self._ensure_compiled() page = self.options.get('page', '') - iframe_url = '/' + self.html_dir + '/index.html?' + page + iframe_url = _doc_root() + self.html_dir + '/index.html?' + page result = [] if 'popup' in self.modes: result.append(Button( @@ -172,13 +172,22 @@ class FlutterAppDirective(SphinxDirective): with open(target_file, 'wt') as out: out.write('\n') out.write('\n\n') - out.write('\n' % self.html_dir) + out.write('\n' % (_doc_root(), self.html_dir)) out.write('%s\n' % self.app_name) out.write('\n\n') out.write('\n') out.write('\n\n') +def _doc_root(): + root = os.environ.get('PUBLISH_PATH', '') + if not root.startswith('/'): + root = '/' + root + if not root.endswith('/'): + root = root + '/' + return root + + # ------------------------------------------------------------------------------ # Nodes # ------------------------------------------------------------------------------