Skip to content

Commit 1673961

Browse files
authored
docs: Take PUBLISH_PATH into account when building docs (#1499)
1 parent 3b80c76 commit 1673961

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

doc/_sphinx/extensions/flutter_app.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def run(self):
8181
self._ensure_compiled()
8282

8383
page = self.options.get('page', '')
84-
iframe_url = '/' + self.html_dir + '/index.html?' + page
84+
iframe_url = _doc_root() + self.html_dir + '/index.html?' + page
8585
result = []
8686
if 'popup' in self.modes:
8787
result.append(Button(
@@ -172,13 +172,22 @@ def _create_index(self):
172172
with open(target_file, 'wt') as out:
173173
out.write('<!DOCTYPE html>\n')
174174
out.write('<html>\n<head>\n')
175-
out.write('<base href="/%s/">\n' % self.html_dir)
175+
out.write('<base href="%s%s/">\n' % (_doc_root(), self.html_dir))
176176
out.write('<title>%s</title>\n' % self.app_name)
177177
out.write('</head>\n<body>\n')
178178
out.write('<script src="main.dart.js"></script>\n')
179179
out.write('</body>\n</html>\n')
180180

181181

182+
def _doc_root():
183+
root = os.environ.get('PUBLISH_PATH', '')
184+
if not root.startswith('/'):
185+
root = '/' + root
186+
if not root.endswith('/'):
187+
root = root + '/'
188+
return root
189+
190+
182191
# ------------------------------------------------------------------------------
183192
# Nodes
184193
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)