예제 #1
0
        public IComment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
        {
            if (options.PreserveWhitespace)
                return new InlineText(node.InnerText.NormaliseIndent());

            return new InlineText(node.InnerText.TrimComment(first, last));
        }
예제 #2
0
 public DocumentationGenerator(string outputPath, string templatePath, ICommentParser commentParser, EventAggregator eventAggregator)
 {
     _outputPath      = outputPath;
     _templatePath    = templatePath;
     _commentParser   = commentParser;
     _eventAggregator = eventAggregator;
 }
예제 #3
0
 public CommentTag(string text, ICommentParser parser, int timeWaitAfterChange = 0)
 {
     Text   = text;
     Parser = parser;
     TimeWaitAfterChange = timeWaitAfterChange;
     Comment             = parser.GetComment(text);
 }
예제 #4
0
        /// <summary>
        /// Parses the specified <see cref="XmlNode" />.
        /// </summary>
        /// <param name="parser">The parser.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// The parsed comment.
        /// </returns>
        public override ParamComment Parse(ICommentParser parser, XmlNode node)
        {
            Debug.Assert(node.Attributes != null, "Node has no attributes.");
            var attribute = node.Attributes["name"];

            return(new ParamComment(attribute.InnerText, ParseChildren(parser, node)));
        }
예제 #5
0
 public DocumentationGenerator(string outputPath, string templatePath, ICommentParser commentParser, EventAggregator eventAggregator)
 {
     _outputPath = outputPath;
     _templatePath = templatePath;
     _commentParser = commentParser;
     _eventAggregator = eventAggregator;
 }
예제 #6
0
        public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
        {
            var attribute     = node.Attributes["name"];
            var parameterName = attribute == null ? string.Empty : attribute.Value;

            return(new ParameterReference(parameterName));
        }
 public void CreateStubs()
 {
     StubParser = MockRepository.GenerateStub <ICommentParser>();
     StubParser.Stub(x => x.Parse(null))
     .IgnoreArguments()
     .Return(new List <Comment>());
 }
예제 #8
0
        /// <summary>
        /// Parses the specified <see cref="XmlNode" />.
        /// </summary>
        /// <param name="parser">The parser.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// The parsed comment.
        /// </returns>
        public override SeeAlsoComment Parse(ICommentParser parser, XmlNode node)
        {
            Debug.Assert(node.Attributes != null, "Node has no attributes.");
            var attribute = node.Attributes["cref"];

            return(new SeeAlsoComment(attribute.InnerText));
        }
예제 #9
0
        /// <summary>
        /// Parses the specified <see cref="XmlNode" />.
        /// </summary>
        /// <param name="parser">The parser.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// The parsed comment.
        /// </returns>
        public override TypeParamRefComment Parse(ICommentParser parser, XmlNode node)
        {
            Debug.Assert(node.Attributes != null, "Node has no attributes.");
            var attribute = node.Attributes["name"];

            return(new TypeParamRefComment(attribute.InnerText));
        }
예제 #10
0
        public IComment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
        {
            if (options.PreserveWhitespace)
            {
                return(new InlineText(node.InnerText.NormaliseIndent()));
            }

            return(new InlineText(node.InnerText.TrimComment(first, last)));
        }
예제 #11
0
 public DataTypeBuilder(IEntityNaming naming,
                        ISyntaxGenerator syntax,
                        IExportableCheck exportable,
                        AttachedMemberCache attachedMembers,
                        ICommentParser commentParser)
     : base(naming, syntax, exportable, attachedMembers)
 {
     _commentParser = commentParser;
 }
예제 #12
0
        /// <summary>
        /// Parses child nodes of the specified <see cref="XmlNode"/>.
        /// </summary>
        /// <param name="parser">The parser.</param>
        /// <param name="node">The node.</param>
        /// <returns>The parsed comments.</returns>
        protected IEnumerable <Comment> ParseChildren(ICommentParser parser, XmlNode node)
        {
            var children = new List <Comment>();

            foreach (XmlNode child in node.ChildNodes)
            {
                children.Add(parser.Parse(child));
            }
            return(children);
        }
예제 #13
0
        /// <summary>
        /// Parses the specified <see cref="XmlNode" />.
        /// </summary>
        /// <param name="parser">The parser.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// The parsed comment.
        /// </returns>
        public override SeeExternalLinkComment Parse(ICommentParser parser, XmlNode node)
        {
            Debug.Assert(node.Attributes != null, "Node has no attributes.");
            var attribute = node.Attributes["href"];
            var link      = attribute?.InnerText;
            var text      = node.InnerText;

            text = string.IsNullOrWhiteSpace(text) ? link : text;
            return(new SeeExternalLinkComment(link, text));
        }
예제 #14
0
 private static bool Validate(string header, ICommentParser commentParser)
 {
     try
     {
         return(commentParser.Parse(header) == header);
     }
     catch (ParseException)
     {
         return(false);
     }
 }
        /// <summary>
        ///   Prepares an updated license header before effectively replacing the old one based on the following rules:
        ///   <para>
        ///     If there's a comment right at the beginning of the file, we need to add an empty line so that the comment
        ///     doesn't become a part of the header.
        ///   </para>
        ///   <para>If there already exists an empty line we don't have to add another one.</para>
        /// </summary>
        /// <param name="headerText">The new header text.</param>
        /// <param name="currentHeaderText">The old, already existing, header text.</param>
        /// <param name="commentParser">An <see cref="ICommentParser" /> instance required for enforcing the described rules.</param>
        /// <returns></returns>
        public static string Prepare(string headerText, string currentHeaderText, ICommentParser commentParser)
        {
            var lineEndingInDocument = NewLineManager.DetectMostFrequentLineEnd(headerText);
            var headerWithNewLine    = NewLineManager.ReplaceAllLineEnds(headerText, lineEndingInDocument);

            if (!CurrentFileStartsWithNewLine(currentHeaderText, lineEndingInDocument) && !HeaderEndsWithNewline(headerWithNewLine, lineEndingInDocument) &&
                CurrentFileContainsCommentOnTop(currentHeaderText, commentParser))
            {
                return(headerWithNewLine + lineEndingInDocument);
            }

            return(headerWithNewLine);
        }
 public void FixtureSetup()
 {
     RealParser = new CommentParser(new ICommentNodeParser[]
     {
         new InlineCodeCommentParser(),
         new InlineListCommentParser(),
         new InlineTextCommentParser(),
         new MultilineCodeCommentParser(),
         new ParagraphCommentParser(),
         new ParameterReferenceParser(),
         new SeeCodeCommentParser(),
     });
 }
예제 #17
0
        public CommentTagger(ITextBuffer buffer, ITagAggregator <IClassificationTag> classificationTag)
        {
            this._buffer            = buffer;
            this._snapshot          = buffer.CurrentSnapshot;
            this._regions           = new List <CommentRegion>();
            this._parser            = CommentParserHelper.GetCommentParser(buffer.ContentType.TypeName);
            this._classificationTag = classificationTag;

            if (_parser != null)
            {
                this.ReParse(null);
                this._buffer.Changed += BufferChanged;
            }
        }
예제 #18
0
        public static string Prepare(string headerText, string currentHeaderText, ICommentParser commentParser)
        {
            var lineEndingInDocument = NewLineManager.DetectMostFrequentLineEnd(headerText);

            var headerWithNewLine = NewLineManager.ReplaceAllLineEnds(headerText, lineEndingInDocument);

            //If there's a comment right at the beginning of the file, we need to add an empty line so that the comment doesn't
            //become a part of the header. If there already exists an empty line we dont have to add another one
            if (!CurrentFileStartsWithNewLine(currentHeaderText, lineEndingInDocument) &&
                !HeaderEndsWithNewline(headerWithNewLine, lineEndingInDocument) &&
                CurrentFileContainsCommentOnTop(currentHeaderText, commentParser))
            {
                return(headerWithNewLine + lineEndingInDocument);
            }

            return(headerWithNewLine);
        }
예제 #19
0
        public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
        {
            IReferencable reference = new NullReference();
            if (node.Attributes["cref"] == null) return new See(reference);
            var referenceTarget = IdentifierFor.XmlString(node.Attributes["cref"].Value);

            if (referenceTarget is NamespaceIdentifier)
                reference = Namespace.Unresolved((NamespaceIdentifier)referenceTarget);
            else if (referenceTarget is TypeIdentifier)
                reference = DeclaredType.Unresolved((TypeIdentifier)referenceTarget, Namespace.Unresolved(referenceTarget.CloneAsNamespace()));
            else if (referenceTarget is MethodIdentifier)
                reference = Method.Unresolved(
                    (MethodIdentifier)referenceTarget,
                    DeclaredType.Unresolved(
                        referenceTarget.CloneAsType(),
                        Namespace.Unresolved(referenceTarget.CloneAsNamespace())
                    )
                );
            else if (referenceTarget is PropertyIdentifier)
                reference = Property.Unresolved(
                    (PropertyIdentifier)referenceTarget,
                    DeclaredType.Unresolved(
                        referenceTarget.CloneAsType(),
                        Namespace.Unresolved(referenceTarget.CloneAsNamespace())
                    )
                );
            else if (referenceTarget is EventIdentifier)
                reference = Event.Unresolved(
                    (EventIdentifier)referenceTarget,
                    DeclaredType.Unresolved(
                        referenceTarget.CloneAsType(),
                        Namespace.Unresolved(referenceTarget.CloneAsNamespace())
                    )
                );
            else if (referenceTarget is FieldIdentifier)
                reference = Field.Unresolved(
                    (FieldIdentifier)referenceTarget,
                    DeclaredType.Unresolved(
                        referenceTarget.CloneAsType(),
                        Namespace.Unresolved(referenceTarget.CloneAsNamespace())
                    )
                );

            return new See(reference);
        }
    public static string Prepare (string headerText, string currentHeaderText, ICommentParser commentParser)
    {
      var lineEndingInDocument = NewLineManager.DetectMostFrequentLineEnd (headerText);


      var headerWithNewLine = headerText;
      var newLine = NewLineManager.DetectMostFrequentLineEnd (headerWithNewLine);

      headerWithNewLine = NewLineManager.ReplaceAllLineEnds (headerWithNewLine, lineEndingInDocument);
      
      //if there's a comment right at the beginning of the file,
      //we need to add an empty line so that the comment doesn't
      //become a part of the header
      if (!string.IsNullOrEmpty (commentParser.Parse (currentHeaderText)) && !headerWithNewLine.EndsWith(lineEndingInDocument + lineEndingInDocument))
        headerWithNewLine += newLine;
      

      return headerWithNewLine;
    }
예제 #21
0
 public XLinqRepository(
     ILogger <XLinqRepository> logger,
     IBadgeParser badgeParser,
     ICommentParser commentParser,
     IPostHistoryParser postHistoryParser,
     IPostParser postParser,
     ITagParser tagParser,
     IUserParser userParser,
     IVoteParser voteParser)
 {
     this.logger            = logger;
     this.badgeParser       = badgeParser;
     this.commentParser     = commentParser;
     this.postHistoryParser = postHistoryParser;
     this.postParser        = postParser;
     this.tagParser         = tagParser;
     this.userParser        = userParser;
     this.voteParser        = voteParser;
 }
예제 #22
0
        public DocumentModel(ICommentParser commentParser, IEventAggregator eventAggregator)
        {
            Namespaces = new NamespaceGenerator(matchedAssociations);
            Types      = new TypeGenerator(matchedAssociations, commentParser);
            Methods    = new MethodGenerator(matchedAssociations, commentParser);
            Properties = new PropertyGenerator(matchedAssociations, commentParser);
            Events     = new EventGenerator(matchedAssociations, commentParser);
            Fields     = new FieldGenerator(matchedAssociations, commentParser);

            this.eventAggregator = eventAggregator;

            steps = new List <IGenerationStep>
            {
                new GenerationStep <IDocumentationMember>(Namespaces.Add),
                new GenerationStep <DocumentedType>(Types.Add),
                new GenerationStep <DocumentedMethod>(Methods.Add),
                new GenerationStep <DocumentedProperty>(Properties.Add),
                new GenerationStep <DocumentedEvent>(Events.Add),
                new GenerationStep <DocumentedField>(Fields.Add),
            };
        }
        public static string Prepare(string headerText, string currentHeaderText, ICommentParser commentParser)
        {
            var lineEndingInDocument = NewLineManager.DetectMostFrequentLineEnd(headerText);


            var headerWithNewLine = headerText;
            var newLine           = NewLineManager.DetectMostFrequentLineEnd(headerWithNewLine);

            headerWithNewLine = NewLineManager.ReplaceAllLineEnds(headerWithNewLine, lineEndingInDocument);

            //if there's a comment right at the beginning of the file,
            //we need to add an empty line so that the comment doesn't
            //become a part of the header
            if (!string.IsNullOrEmpty(commentParser.Parse(currentHeaderText)) && !headerWithNewLine.EndsWith(lineEndingInDocument + lineEndingInDocument))
            {
                headerWithNewLine += newLine;
            }


            return(headerWithNewLine);
        }
예제 #24
0
        public DocumentModel(ICommentParser commentParser, IEventAggregator eventAggregator)
        {
            Namespaces = new NamespaceGenerator(matchedAssociations);
            Types = new TypeGenerator(matchedAssociations, commentParser);
            Methods = new MethodGenerator(matchedAssociations, commentParser);
            Properties = new PropertyGenerator(matchedAssociations, commentParser);
            Events = new EventGenerator(matchedAssociations, commentParser);
            Fields = new FieldGenerator(matchedAssociations, commentParser);

            this.eventAggregator = eventAggregator;

            steps = new List<IGenerationStep>
            {
                new GenerationStep<IDocumentationMember>(Namespaces.Add),
                new GenerationStep<DocumentedType>(Types.Add),
                new GenerationStep<DocumentedMethod>(Methods.Add),
                new GenerationStep<DocumentedProperty>(Properties.Add),
                new GenerationStep<DocumentedEvent>(Events.Add),
                new GenerationStep<DocumentedField>(Fields.Add),
            };
        }
예제 #25
0
 public IComment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
 {
     var typeAttribute = node.Attributes["type"];
     var listTypeName = typeAttribute == null ? string.Empty : typeAttribute.Value;
     var list = createListForType(listTypeName);
     foreach (XmlNode itemNode in node.SelectNodes("item"))
     {
         Paragraph term = null;
         Paragraph definition = null;
         var termNode = itemNode.SelectSingleNode("term");
         if (termNode != null)
         {
             term = new Paragraph(parser.Parse(termNode.ChildNodes));
         }
         var definitionNode = itemNode.SelectSingleNode("description");
         if (definitionNode != null)
         {
             definition = new Paragraph(parser.Parse(definitionNode.ChildNodes));
         }
         list.Items.Add(new InlineListItem(term, definition));
     }
     return list;
 }
예제 #26
0
        public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
        {
            var typeAttribute = node.Attributes["type"];
            var listTypeName  = typeAttribute == null ? string.Empty : typeAttribute.Value;
            var list          = createListForType(listTypeName);

            foreach (XmlNode itemNode in node.SelectNodes("item"))
            {
                Paragraph term       = null;
                Paragraph definition = null;
                var       termNode   = itemNode.SelectSingleNode("term");
                if (termNode != null)
                {
                    term = new Paragraph(parser.Parse(termNode.ChildNodes));
                }
                var definitionNode = itemNode.SelectSingleNode("description");
                if (definitionNode != null)
                {
                    definition = new Paragraph(parser.Parse(definitionNode.ChildNodes));
                }
                list.Items.Add(new InlineListItem(term, definition));
            }
            return(list);
        }
예제 #27
0
 /// <summary>
 /// Parses the specified <see cref="XmlNode" />.
 /// </summary>
 /// <param name="parser">The parser.</param>
 /// <param name="node">The node.</param>
 /// <returns>
 /// The parsed comment.
 /// </returns>
 public override SummaryComment Parse(ICommentParser parser, XmlNode node)
 {
     return(new SummaryComment(ParseChildren(parser, node)));
 }
예제 #28
0
 public JavaScriptReferenceParser(ICommentParser commentParser)
     : base(commentParser)
 {
 }
예제 #29
0
 protected BaseGenerator(ICommentParser commentParser)
 {
     _commentParser = commentParser;
 }
예제 #30
0
 public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
 {
     return new InlineCode(node.InnerText.TrimComment(first, last));
 }
예제 #31
0
 public AbConfigParser(ICommentParser commentParser)
 {
     this.commentParser = commentParser;
 }
예제 #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseGenerator"/> class.
 /// </summary>
 /// <param name="commentParser">
 /// The comment parser.
 /// </param>
 protected BaseGenerator(ICommentParser commentParser)
 {
     this.commentParser = commentParser;
 }
예제 #33
0
 internal virtual ReferenceParser CreateReferenceParser(ICommentParser commentParser)
 {
     return(new ReferenceParser(commentParser));
 }
예제 #34
0
 public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
 {
     return new Paragraph(parser.Parse(node.ChildNodes));
 }
예제 #35
0
 public JavaScriptReferenceParser(ICommentParser commentParser)
     : base(commentParser)
 {
 }
예제 #36
0
 public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
 {
     return(new InlineCode(node.InnerText.TrimComment(true, true)));
 }
예제 #37
0
 /// <summary>
 /// Parses the specified <see cref="XmlNode"/>.
 /// </summary>
 /// <param name="parser">The parser.</param>
 /// <param name="node">The node.</param>
 /// <returns>The parsed comment.</returns>
 public abstract T Parse(ICommentParser parser, XmlNode node);
예제 #38
0
 internal override ReferenceParser CreateReferenceParser(ICommentParser commentParser)
 {
     return(new JavaScriptReferenceParser(commentParser));
 }
예제 #39
0
 public ReferenceParser(ICommentParser commentParser)
 {
     this.commentParser = commentParser;
 }
 public IComment Parse(ICommentParser parser, XmlNode node, bool first, bool last)
 {
     return new InlineCode(node.InnerText.TrimComment(true, true));
 }
예제 #41
0
 public PropertyGenerator(
     IDictionary <Identifier, IReferencable> matchedAssociations, ICommentParser commentParser)
     : base(commentParser)
 {
     _matchedAssociations = matchedAssociations;
 }
예제 #42
0
 /// <summary>
 /// Parses the specified <see cref="XmlNode" />.
 /// </summary>
 /// <param name="parser">The parser.</param>
 /// <param name="node">The node.</param>
 /// <returns>The parsed comment.</returns>
 IComment ICommentNodeParser.Parse(ICommentParser parser, XmlNode node)
 {
     return(Parse(parser, node));
 }
예제 #43
0
 public FieldGenerator( IDictionary<Identifier, IReferencable> matchedAssociations, ICommentParser commentParser )
     : base(commentParser)
 {
     this.matchedAssociations = matchedAssociations;
 }
예제 #44
0
 public TypeGenerator(IDictionary <Identifier, IReferencable> matchedAssociations, ICommentParser commentParser)
     : base(commentParser)
 {
     this.matchedAssociations = matchedAssociations;
 }
 public IComment Parse(ICommentParser parser, XmlNode node, bool first, bool last)
 {
     var attribute = node.Attributes["name"];
     var parameterName = attribute == null ? string.Empty : attribute.Value;
     return new ParameterReference(parameterName);
 }
예제 #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XmlDocumentationParser"/> class.
 /// </summary>
 public XmlDocumentationParser()
 {
     _parser = new CommentParser();
 }
예제 #47
0
 public IComment Parse(ICommentParser parser, XmlNode node, bool first, bool last)
 {
     return new InlineText(node.InnerText.TrimComment(first, last));
 }