Exemple #1
0
        public DocumentationGenerator(
            IMarkdownWriter writer,
            TypeCollection typeCollection,
            Type firstType = null)
        {
            Reader          = new DocXmlReader();
            Writer          = writer;
            TypeCollection  = typeCollection;
            TypesToDocument = typeCollection.ReferencedTypes.Values
                              .OrderBy(t => t.Type.Namespace)
                              .ThenBy(t => t.Type.Name).ToList();
            if (firstType != null)
            {
                var typeDesc = TypesToDocument.FirstOrDefault(t => t.Type == firstType);
                if (typeDesc != null)
                {
                    TypesToDocument.Remove(typeDesc);
                    TypesToDocument.Insert(0, typeDesc);
                }
            }

            TypesToDocumentSet = new HashSet <Type>(TypesToDocument.Select(t => t.Type));
            typeLinkConverter  = (type, _) => TypesToDocumentSet.Contains(type) ?
                                 Writer.HeadingLink(TypeTitle(type), type.ToNameString()) : null;
        }
Exemple #2
0
        public OrderedTypeList(TypeCollection typeCollection, Type firstType = null)
        {
            TypeCollection  = typeCollection;
            TypesToDocument = typeCollection.ReferencedTypes.Values
                              .OrderBy(t => t.Type.Namespace)
                              .ThenBy(t => t.Type.Name).ToList();
            TypesToDocumentSet = new HashSet <Type>(TypesToDocument.Select(t => t.Type));

            if (firstType != null)
            {
                var typeDesc = TypesToDocument.FirstOrDefault(t => t.Type == firstType);
                if (typeDesc != null)
                {
                    TypesToDocument.Remove(typeDesc);
                    TypesToDocument.Insert(0, typeDesc);
                }
            }
        }
        public DocumentationGenerator(
            IMarkdownWriter writer,
            TypeCollection typeCollection,
            Type firstType  = null,
            bool msdnLinks  = false,
            string msdnView = null)
        {
            Reader          = new DocXmlReader();
            Writer          = writer;
            TypeCollection  = typeCollection;
            TypesToDocument = typeCollection.ReferencedTypes.Values
                              .OrderBy(t => t.Type.Namespace)
                              .ThenBy(t => t.Type.Name).ToList();
            if (firstType != null)
            {
                var typeDesc = TypesToDocument.FirstOrDefault(t => t.Type == firstType);
                if (typeDesc != null)
                {
                    TypesToDocument.Remove(typeDesc);
                    TypesToDocument.Insert(0, typeDesc);
                }
            }

            TypesToDocumentSet = new HashSet <Type>(TypesToDocument.Select(t => t.Type));
            typeLinkConverter  = (type, _) =>
            {
                if (TypesToDocumentSet.Contains(type))
                {
                    return(Writer.HeadingLink(TypeTitle(type), type.ToNameString()));
                }
                if (msdnLinks &&
                    (type.Assembly.ManifestModule.Name.StartsWith("System.") ||
                     type.Assembly.ManifestModule.Name.StartsWith("Microsoft.")))
                {
                    return(Writer.Link(MsdnUrlForType(type, msdnView),
                                       type.IsGenericTypeDefinition ? type.Name.CleanGenericTypeName() : type.ToNameString()));
                }
                if (type.IsGenericTypeDefinition)
                {
                    return($"{type.Name.CleanGenericTypeName()}");
                }
                return(null);
            };
        }
        /// <summary>
        /// Write table of contents. It is a three column table with each cell containing
        /// the link to the heading of the type.
        /// </summary>
        /// <param name="indexTitleText"></param>
        public void WriteTypeIndex(string indexTitleText = "Contents")
        {
            var namesForTOC = TypesToDocument
                              .Select(typeData => Writer.HeadingLink(TypeTitle(typeData.Type), TypeTitle(typeData.Type))).ToList();

            if (namesForTOC.Count == 0)
            {
                return;
            }

            if (indexTitleText != null)
            {
                Writer.WriteH1(indexTitleText);
            }
            var rowCount = namesForTOC.Count;

            for (var i = 0; i < rowCount; i++)
            {
                Writer.Write($"- {namesForTOC[i]}");
            }
        }
Exemple #5
0
        /// <summary>
        /// Write table of contents. It is a three column table with each cell containing
        /// the link to the heading of the type.
        /// </summary>
        /// <param name="indexTitleText"></param>
        public void WriteTypeIndex(string indexTitleText = "All types")
        {
            var namesForTOC = TypesToDocument
                              .Select(typeData => Writer.HeadingLink(TypeTitle(typeData.Type), TypeTitle(typeData.Type))).ToList();

            if (namesForTOC.Count == 0)
            {
                return;
            }

            if (indexTitleText != null)
            {
                Writer.WriteH1(indexTitleText);
            }
            Writer.WriteTableTitle(" ", " ", " ");
            var rowCount = namesForTOC.Count / 3 + (((namesForTOC.Count % 3) == 0) ? 0 : 1);

            for (var i = 0; i < rowCount; i++)
            {
                Writer.WriteTableRow(namesForTOC[i],
                                     rowCount + i < namesForTOC.Count ? namesForTOC[rowCount + i] : " ",
                                     rowCount * 2 + i < namesForTOC.Count ? namesForTOC[rowCount * 2 + i] : " ");
            }
        }