docs: Take PUBLISH_PATH into account when building docs (#1499)

This commit is contained in:
Pasha Stetsenko
2022-03-28 02:23:03 -07:00
committed by GitHub
parent 3b80c767fe
commit 167396142e

View File

@ -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('<!DOCTYPE html>\n')
out.write('<html>\n<head>\n')
out.write('<base href="/%s/">\n' % self.html_dir)
out.write('<base href="%s%s/">\n' % (_doc_root(), self.html_dir))
out.write('<title>%s</title>\n' % self.app_name)
out.write('</head>\n<body>\n')
out.write('<script src="main.dart.js"></script>\n')
out.write('</body>\n</html>\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
# ------------------------------------------------------------------------------