@@ -93,28 +93,34 @@ function update_canonical_links(
93
93
end
94
94
canonical_full_root = joinurl (canonical, canonical_path... )
95
95
# If we have determined which version should be the canonical version, we can actually
96
- # go and run update_canonical_links_for_version on each directory.
97
- for filename in readdir (docs_directory)
98
- path = joinpath (docs_directory, filename)
96
+ # go and run update_canonical_links_for_version on each directory. First, we'll gather
97
+ # up the list of Documenter (or other) directories we actually want to run over.
98
+ docs_subdirectory_queue, docs_subdirectories = readdir (docs_directory), []
99
+ while ! isempty (docs_subdirectory_queue)
100
+ docs_subdirectory = popfirst! (docs_subdirectory_queue)
101
+ path = joinpath (docs_directory, docs_subdirectory)
99
102
# We'll skip all files. This includes files such as index.html, which in this
100
103
# directory will likely be the redirect. Also, links should be pointing to other
101
104
# versions, so we'll skip them too.
102
- if islink (path) || ! isdir (path)
105
+ if ! isdir (path) || islink (path)
103
106
continue
104
107
end
105
- # For true directories, we check that siteinfo.js file is present, which is a pretty
106
- # good indicator that it's a proper Documenter build.
107
- if ! isfile (joinpath (path, " siteinfo.js" ))
108
- # We want to warn if we run across any directories that are not Documenter builds.
109
- # But previews/ is one valid case which may be present and so we shouldn't warn
110
- # for this one.
111
- if filename != " previews"
112
- @warn " update_canonical_links: skipping directory that does not look like a Documenter build" filename docs_directory
113
- end
108
+ # Preview directory is should contain other Documenter directories, so we just add
109
+ # the subdirectories into the queue and ignore the parent directory itself
110
+ if docs_subdirectory == " previews"
111
+ append! (docs_subdirectory_queue, joinpath .(docs_subdirectory, readdir (path)))
114
112
continue
115
113
end
116
- # Finally, we can run update_canonical_links_for_version on the directory.
117
- @debug " Updating canonical URLs for version" docs_directory filename canonical_full_root
114
+ # For other directories, we check for the presence of siteinfo.js, and warn if that
115
+ # is missing (but we still try to go and update the canonical URLs).
116
+ if ! isfile (joinpath (path, " siteinfo.js" ))
117
+ @warn " update_canonical_links: missing siteinfo.js file" path
118
+ end
119
+ push! (docs_subdirectories, path)
120
+ end
121
+ # Finally, we can run update_canonical_links_for_version on the directory.
122
+ for path in docs_subdirectories
123
+ @debug " Updating canonical URLs for a version" path canonical_full_root
118
124
update_canonical_links_for_version (path; canonical = canonical_full_root)
119
125
end
120
126
end
0 commit comments