/// <summary> /// Let the add-on to prepare it's own data as a part of <see cref="RootMember"/> constructor. /// </summary> /// <remarks> /// The add-on checks all compilation files for the <NuProp.xxx> comments with source-only package metadata /// and builds the list of source-only packages and the indexes between the packages and code model members. /// </remarks> /// <param name="root">Code model root</param> /// <param name="builder">Code model buildel root</param> public void ProcessRootData(RootMember root, RootMemberBuilder builder) { ConsoleUtils.WriteInfo("SourceOnlyPackagesAddOn preparing data..."); //Get source-only packages info var packages = new List <NuProps>(); SourceOnlyPackages = packages; var sourceOnlyPackagesByMember = new Dictionary <Member, List <NuProps> >(); SourceOnlyPackagesByMember = sourceOnlyPackagesByMember; var membersBySourceOnlyPackage = new Dictionary <NuProps, List <Member> >(); MembersBySourceOnlyPackage = membersBySourceOnlyPackage; foreach (var compilationFile in builder.CompilationFiles) { var nuProps = new NuProps(compilationFile, builder.CompilationFiles); if (!nuProps.HasNuProps) { continue; } packages.Add(nuProps); //add members to indexes foreach (var packageFile in nuProps.PackageFiles) { if (!root.AllMembersBySourceFile.TryGetValue(packageFile, out var packageMembers)) { continue; } foreach (var packageMember in packageMembers) { if (!sourceOnlyPackagesByMember.TryGetValue(packageMember, out var packagesForMember)) { packagesForMember = new List <NuProps>(); sourceOnlyPackagesByMember.Add(packageMember, packagesForMember); } packagesForMember.Add(nuProps); if (!membersBySourceOnlyPackage.TryGetValue(nuProps, out var membersForPackage)) { membersForPackage = new List <Member>(); membersBySourceOnlyPackage.Add(nuProps, membersForPackage); } membersForPackage.Add(packageMember); } } } ConsoleUtils.WriteInfo($"SourceOnlyPackagesAddOn finished preparing data - {packages.Count} source only packages found"); }
/// <summary> /// Creates the link to the <see cref="package"/> page /// </summary> /// <param name="text">Link text</param> /// <param name="package">Package metadata</param> /// <param name="markup">Markup provider</param> /// <returns>Markup with the link to the <param name="package"></param></returns> private string Link(string text, NuProps package, IMarkupProvider markup) { var fileName = string.Empty; if (OutputOptions.SplitNs && !OutputOptions.SplitType) { fileName = GetPackagePagesFileName(); } if (OutputOptions.SplitType) { fileName = GetPackagePageFileName(package); } var extension = markup.Extension; return(markup.Link(text, string.IsNullOrEmpty(fileName) ? "" : $"{fileName}.{extension}", GetPackageAnchor(package))); }
/// <summary> /// Returns the name of the generated file (without extension) for <see cref="package"/> when the split by type is set, so the all package pages are generated into dedicated files. /// </summary> ///<param name="package">Package metadata</param> /// <returns>The name of the generated file (without extension) when the split by namespace is set, so the all package pages are generated into dedicated files</returns> private string GetPackagePageFileName(NuProps package) { return($"src-only-package--{package.PackageId}"); }
/// <summary> /// Returns the anchor for given <see cref="package"/> within the package page(s) file. /// </summary> ///<param name="package">Package metadata</param> /// <returns>Anchor for given <see cref="package"/> within the package page(s) file</returns> private string GetPackageAnchor(NuProps package) { return($"src-only-package--{package.PackageId}"); }