Пример #1
0
            public override QsCustomType OnTypeDeclaration(QsCustomType type)
            {
                type = base.OnTypeDeclaration(type);
                // If the UDT didn't come from a Q# source file, then it
                // came in from a reference, and shouldn't be documented in this
                // project.
                if (!type.IsInCompilationUnit())
                {
                    return(type);
                }

                var isDeprecated = type.IsDeprecated(out var replacement);
                var docComment   = new DocComment(
                    type.Documentation, type.FullName.Name,
                    deprecated: isDeprecated,
                    replacement: replacement
                    );

                // Validate named item names.
                var inputDeclarations = type.TypeItems.ToDictionaryOfDeclarations();

                this.ValidateNames(
                    $"{type.FullName.Namespace}.{type.FullName.Name}",
                    "named item",
                    name => inputDeclarations.ContainsKey(name),
                    docComment.Input.Keys,
                    range: null, // TODO: provide more exact locations once supported by DocParser.
                    source: type.SourceFile
                    );

                this.writer?.WriteOutput(type, docComment)?.Wait();

                return(type
                       .AttributeBuilder()
                       .MaybeWithSimpleDocumentationAttribute("Summary", docComment.Summary)
                       .MaybeWithSimpleDocumentationAttribute("Description", docComment.Description)
                       .MaybeWithSimpleDocumentationAttribute("Remarks", docComment.Remarks)
                       .MaybeWithSimpleDocumentationAttribute("References", docComment.References)
                       .WithListOfDocumentationAttributes("SeeAlso", docComment.SeeAlso)
                       .WithListOfDocumentationAttributes("Example", docComment.Examples)
                       .WithDocumentationAttributesFromDictionary("NamedItem", docComment.NamedItems)
                       .Build());
            }