in src/Elastic.Markdown/IO/DocumentationSet.cs [117:189]
public DocumentationSet(
BuildContext context,
ILoggerFactory logger,
ICrossLinkResolver? linkResolver = null,
TableOfContentsTreeCollector? treeCollector = null
)
{
Context = context;
Source = ContentSourceMoniker.Create(context.Git.RepositoryName, null);
SourceDirectory = context.DocumentationSourceDirectory;
OutputDirectory = context.DocumentationOutputDirectory;
LinkResolver =
linkResolver ?? new CrossLinkResolver(new ConfigurationCrossLinkFetcher(context.Configuration, logger));
Configuration = context.Configuration;
EnabledExtensions = InstantiateExtensions();
treeCollector ??= new TableOfContentsTreeCollector();
var resolver = new ParserResolvers
{
CrossLinkResolver = LinkResolver,
DocumentationFileLookup = DocumentationFileLookup
};
MarkdownParser = new MarkdownParser(context, resolver);
Name = Context.Git != GitCheckoutInformation.Unavailable
? Context.Git.RepositoryName
: Context.DocumentationCheckoutDirectory?.Name ?? $"unknown-{Context.DocumentationSourceDirectory.Name}";
OutputStateFile = OutputDirectory.FileSystem.FileInfo.New(Path.Combine(OutputDirectory.FullName, ".doc.state"));
LinkReferenceFile = OutputDirectory.FileSystem.FileInfo.New(Path.Combine(OutputDirectory.FullName, "links.json"));
var files = ScanDocumentationFiles(context, SourceDirectory);
var additionalSources = EnabledExtensions
.SelectMany(extension => extension.ScanDocumentationFiles(DefaultFileHandling))
.ToArray();
Files = files.Concat(additionalSources).Where(f => f is not ExcludedFile).ToArray();
LastWrite = Files.Max(f => f.SourceFile.LastWriteTimeUtc);
FlatMappedFiles = Files.ToDictionary(file => file.RelativePath, file => file).ToFrozenDictionary();
FilesGroupedByFolder = Files
.GroupBy(file => file.RelativeFolder)
.ToDictionary(g => g.Key, g => g.ToArray())
.ToFrozenDictionary();
var fileIndex = 0;
var lookups = new NavigationLookups
{
FlatMappedFiles = FlatMappedFiles,
TableOfContents = Configuration.TableOfContents,
EnabledExtensions = EnabledExtensions,
FilesGroupedByFolder = FilesGroupedByFolder,
//IndexedTableOfContents = indexedTableOfContents ?? new Dictionary<Uri, TableOfContentsReference>().ToFrozenDictionary()
};
Tree = new TableOfContentsTree(this, Source, Context, lookups, treeCollector, ref fileIndex);
var markdownFiles = Files.OfType<MarkdownFile>().ToArray();
var excludedChildren = markdownFiles.Where(f => f.NavigationIndex == -1).ToArray();
foreach (var excludedChild in excludedChildren)
Context.EmitError(Context.ConfigurationPath, $"{excludedChild.RelativePath} is unreachable in the TOC because one of its parents matches exclusion glob");
MarkdownFiles = markdownFiles.Where(f => f.NavigationIndex > -1).ToDictionary(i => i.NavigationIndex, i => i).ToFrozenDictionary();
MarkdownNavigationLookup = Tree.NavigationItems
.SelectMany(Pairs)
.ToDictionary(kv => kv.Item1, kv => kv.Item2)
.ToFrozenDictionary();
ValidateRedirectsExists();
}