@@ -100,15 +100,18 @@ def _build_modidx(dest=None, nbs_path=None, skip_exists=False):
100100
101101# %% ../nbs/api/doclinks.ipynb 20
102102@delegates (globtastic )
103- def nbglob (path = None , skip_folder_re = '^[_.]' , file_glob = '*.ipynb' , skip_file_re = '^[_.]' , key = 'nbs_path' , as_path = False , ** kwargs ):
103+ def nbglob (path = None , skip_folder_re = '^[_.]' , file_glob = '*.ipynb' , skip_file_re = '^[_.]' , key = 'nbs_path' , as_path = False , sort_by = None , ** kwargs ):
104104 "Find all files in a directory matching an extension given a config key."
105105 path = Path (path or get_config ()[key ])
106106 recursive = get_config ().recursive
107107 res = globtastic (path , file_glob = file_glob , skip_folder_re = skip_folder_re ,
108108 skip_file_re = skip_file_re , recursive = recursive , ** kwargs )
109- return res .map (Path ) if as_path else res
109+ res = res .map (Path ) if as_path else res
110+ if sort_by is not None :
111+ res .sort (key = sort_by )
112+ return res
110113
111- # %% ../nbs/api/doclinks.ipynb 21
114+ # %% ../nbs/api/doclinks.ipynb 23
112115def nbglob_cli (
113116 path :str = None , # Path to notebooks
114117 symlinks :bool = False , # Follow symlinks?
@@ -122,24 +125,24 @@ def nbglob_cli(
122125 return nbglob (path , symlinks = symlinks , file_glob = file_glob , file_re = file_re , folder_re = folder_re ,
123126 skip_file_glob = skip_file_glob , skip_file_re = skip_file_re , skip_folder_re = skip_folder_re )
124127
125- # %% ../nbs/api/doclinks.ipynb 22
128+ # %% ../nbs/api/doclinks.ipynb 24
126129@call_parse
127130@delegates (nbglob_cli )
128131def nbdev_export (
129132 path :str = None , # Path or filename
130133 ** kwargs ):
131134 "Export notebooks in `path` to Python modules"
132135 if os .environ .get ('IN_TEST' ,0 ): return
133- files = nbglob (path = path , ** kwargs )
136+ files = nbglob (path = path , as_path = True , sort_by = lambda path_str : Path ( path_str ). name , ** kwargs )
134137 for f in files : nb_export (f )
135138 add_init (get_config ().lib_path )
136139 _build_modidx ()
137140
138- # %% ../nbs/api/doclinks.ipynb 24
141+ # %% ../nbs/api/doclinks.ipynb 26
139142import importlib ,ast
140143from functools import lru_cache
141144
142- # %% ../nbs/api/doclinks.ipynb 25
145+ # %% ../nbs/api/doclinks.ipynb 27
143146def _find_mod (mod ):
144147 mp ,_ ,mr = mod .partition ('/' )
145148 spec = importlib .util .find_spec (mp )
@@ -162,7 +165,7 @@ def _get_exps(mod):
162165
163166def _lineno (sym , fname ): return _get_exps (fname ).get (sym , None ) if fname else None
164167
165- # %% ../nbs/api/doclinks.ipynb 27
168+ # %% ../nbs/api/doclinks.ipynb 29
166169def _qual_sym (s , settings ):
167170 if not isinstance (s ,tuple ): return s
168171 nb ,py = s
@@ -177,10 +180,10 @@ def _qual_syms(entries):
177180 if 'doc_host' not in settings : return entries
178181 return {'syms' : {mod :_qual_mod (d , settings ) for mod ,d in entries ['syms' ].items ()}, 'settings' :settings }
179182
180- # %% ../nbs/api/doclinks.ipynb 28
183+ # %% ../nbs/api/doclinks.ipynb 30
181184_re_backticks = re .compile (r'`([^`\s]+)`' )
182185
183- # %% ../nbs/api/doclinks.ipynb 29
186+ # %% ../nbs/api/doclinks.ipynb 31
184187@lru_cache (None )
185188class NbdevLookup :
186189 "Mapping from symbol names to docs and source URLs"
0 commit comments