docs: Fixed linked joints examples (#2400)

Embedded flutter-app joints examples didn't work, because flutter-app script expects the example page to be located in the lib folder of a module. Introduced a new subfolder param, to specify where to find the example page.

Verified joints examples apps and code button on the doc page work; Also verified the same for the effects page.
This commit is contained in:
Eugene Kleshnin
2023-03-13 11:25:49 +00:00
committed by GitHub
parent 35d5533ded
commit 4293343a2e
2 changed files with 29 additions and 25 deletions

View File

@ -44,6 +44,9 @@ class FlutterAppDirective(SphinxDirective):
In addition, the "code" run mode will try to locate a file or a folder
with the matching name.
:subfolder: - optional parameter, needed if the app page is not located in the lib folder.
The value of the parameter should be the path from the lib folder to the page source file.
:show: - a list of one or more run modes, which could include "widget",
"popup", "code", and "infobox". Each of these modes produces a different
output:
@ -65,6 +68,7 @@ class FlutterAppDirective(SphinxDirective):
option_spec = {
'sources': directives.unchanged,
'page': directives.unchanged,
'subfolder': directives.unchanged,
'show': directives.unchanged,
'width': directives.unchanged,
'height': directives.unchanged,
@ -222,7 +226,10 @@ class FlutterAppDirective(SphinxDirective):
out.write('</body>\n</html>\n')
def _generate_code_listings(self, code_id):
code_dir = self.source_dir + '/lib/' + self.options.get('page', '')
subfolder = self.options.get('subfolder', '')
if subfolder and not subfolder.endswith('/'):
subfolder += '/'
code_dir = self.source_dir + '/lib/' + subfolder + self.options.get('page', '')
if os.path.isdir(code_dir):
files = glob.glob(code_dir + '/**', recursive=True)
elif os.path.isfile(code_dir + '.dart'):