Exemplo n.º 1
0
        /// <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 &lt;NuProp.xxx&gt; 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");
        }
Exemplo n.º 2
0
        /// <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)));
        }
Exemplo n.º 3
0
 /// <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}");
 }
Exemplo n.º 4
0
 /// <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}");
 }