1616 "link" : ["meta_copydoc" ],
1717}
1818
19+ EXCLUDE_PATHS = ["partials" ]
20+
1921
2022def is_index (path ):
2123 return path .name == "index.html"
@@ -39,6 +41,17 @@ def is_template(path):
3941 return False
4042
4143
44+ def is_partial (path ):
45+ """
46+ Return True if the file name starts with an underscore,
47+ that indicates it as a partial
48+
49+ Partials are templates that are not meant to be rendered directly, but
50+ included in other templates.
51+ """
52+ return path .name .startswith ("_" )
53+
54+
4255def append_base_path (base , path_name ):
4356 """
4457 Add the base (root) to a path URI.
@@ -204,7 +217,10 @@ def is_valid_page(path, extended_path, is_index=True):
204217 - They contain the same extended path as the index html.
205218 - They extend from the base html.
206219 """
207- if is_template (path ):
220+
221+ path = Path (path )
222+
223+ if not path .is_file () or is_template (path ) or is_partial (path ):
208224 return False
209225
210226 if not is_index and extended_path :
@@ -222,9 +238,9 @@ def get_extended_path(path):
222238 """Get the path extended by the file"""
223239 with path .open ("r" ) as f :
224240 for line in f .readlines ():
225- # TODO: also match single quotes \'
226- if match := re .search ("{% extends [\" '](.*?)[\" '] %}" , line ):
227- return match .group (1 )
241+ if ".html" in str ( path ):
242+ if match := re .search ("{% extends [\" '](.*?)[\" '] %}" , line ):
243+ return match .group (1 )
228244
229245
230246def update_tags (tags , new_tags ):
@@ -245,6 +261,7 @@ def create_node():
245261 "description" : None ,
246262 "link" : None ,
247263 "children" : [],
264+ "ext" : None ,
248265 }
249266
250267
@@ -256,6 +273,11 @@ def scan_directory(path_name, base=None):
256273 node = create_node ()
257274 node ["name" ] = path_name .split ("/templates" , 1 )[- 1 ]
258275
276+ # Skip scanning directory if it is in excluded paths
277+ for path in EXCLUDE_PATHS :
278+ if re .search (path , node ["name" ]):
279+ return node
280+
259281 # We get the relative parent for the path
260282 if base is None :
261283 base = node_path .absolute ()
@@ -278,6 +300,9 @@ def scan_directory(path_name, base=None):
278300 tags = get_tags_rolling_buffer (index_path )
279301 node = update_tags (node , tags )
280302
303+ else :
304+ node ["ext" ] = ".dir"
305+
281306 # Cycle through other files in this directory
282307 for child in node_path .iterdir ():
283308 # If the child is a file, check if it is a valid page
@@ -287,6 +312,7 @@ def scan_directory(path_name, base=None):
287312 child , extended_path , is_index = False
288313 ):
289314 child_tags = get_tags_rolling_buffer (child )
315+ child_tags ["ext" ] = child .suffix
290316 # If the child has no copydocs link, use the parent's link
291317 if not child_tags .get ("link" ) and extended_path :
292318 child_tags ["link" ] = get_extended_copydoc (
0 commit comments