@@ -106,17 +106,25 @@ def __iter__(self):
106106 return iter (retlist )
107107
108108
109- def is_excluded_dir (path : Path , settings : ProjectSettings ) -> bool :
109+ def is_excluded_dir (path : Path , settings : ProjectSettings ) -> Optional [ str ] :
110110 """Should `path` be excluded from the pagetree?"""
111- paths_to_exclude : set [Path ] = {
112- path
113- for path in [settings .graph_dir , settings .media_dir , settings .output_dir ]
114- if path is not None
115- }
116- paths_to_exclude .update (settings .html_template_dir )
117- paths_to_exclude .update (settings .src_dir )
118111
119- return path in paths_to_exclude
112+ if path == settings .graph_dir :
113+ return "it is set as 'graph_dir'"
114+
115+ if path == settings .media_dir :
116+ return "it is set as 'media_dir'"
117+
118+ if path == settings .output_dir :
119+ return "it is set as 'output_dir'"
120+
121+ if path in settings .html_template_dir :
122+ return "it is set as 'html_template_dir'"
123+
124+ if path in settings .src_dir :
125+ return "it is set as 'src_dir'"
126+
127+ return None
120128
121129
122130def get_page_tree (
@@ -134,13 +142,19 @@ def get_page_tree(
134142 # I will use this later to remove duplicates from a list in a short way.
135143 from collections import OrderedDict
136144
137- if is_excluded_dir (topdir , settings ):
138- # Would be nice to be able to report if directory was excluded and why
139- return None
140-
141145 # look for files within topdir
142146 index_file = topdir / "index.md"
143147
148+ # Ignore Ford directories if they're under `page_dir`, giving a warning if
149+ # there's an `index.md` under them
150+ if (reason := is_excluded_dir (topdir , settings )) is not None :
151+ if index_file .exists ():
152+ warn (
153+ f"Ignoring '{ topdir } ' from pages, because { reason } .\n "
154+ f" Either remove '{ index_file } ' or move it to another directory\n "
155+ )
156+ return None
157+
144158 if not index_file .exists ():
145159 warn (f"'{ index_file } ' does not exist" )
146160 return None
0 commit comments