Answer architecture round 1: a module's reads sits on its index entry or, for a source without an index, in the load that walks it, the note names default modules, the shipped modules are listed by name, datafiles drops its unused base, and item 195 files the builtins' second parse

This commit is contained in:
2026-10-10 13:16:59 +02:00
committed by Lillem4n
parent e8b7d95559
commit 50e1a9fb22
14 changed files with 120 additions and 59 deletions
+11 -5
View File
@@ -8,30 +8,36 @@ import (
// loadSources merges sources in order, the last winning a clash. A source whose manifest
// carries an index leaves its categories unloaded; every other source loads here, with
// the unloaded categories it needs.
// the unloaded categories it needs: docs/decisions.md#a-source-whose-manifest-carries-an-index-loads-each-category-on-first-reach-any-other-loads-in-new-with-what-it-reads
func loadSources(sources []datafiles.Source) (folder, error) {
root := folder{children: map[string]node{}}
defaultModules := map[string][]string{}
for _, src := range sources {
if err := addSource(&root, src); err != nil {
if err := addSource(&root, src, defaultModules); err != nil {
return folder{}, err
}
}
return root, loadReached(&root, categorySites(&root), nil)
return root, loadReached(&root, categorySites(&root), nil, defaultModules)
}
func addSource(root *folder, src datafiles.Source) error {
// addSource places src's categories in root, and sets in defaultModules, for each category
// it loads, the modules src reads by default.
func addSource(root *folder, src datafiles.Source, defaultModules map[string][]string) error {
m, err := src.Manifest()
if err != nil {
return err
}
if m.Index != nil {
placeIndex(root, src, m.Index)
placeIndex(root, src, m)
return nil
}
g := &folder{children: map[string]node{}}
if err := src.Walk(compileInto(func(dir []string) *folder { return madeFolder(g, dir) })); err != nil {
return err
}
for _, s := range categorySites(g) {
defaultModules[s.path] = m.Reads
}
mergeFolder(root, g)
return nil
}