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));
        }
Exemple #2
0
 public DocumentationGenerator(string outputPath, string templatePath, ICommentParser commentParser, EventAggregator eventAggregator)
 {
     _outputPath      = outputPath;
     _templatePath    = templatePath;
     _commentParser   = commentParser;
     _eventAggregator = eventAggregator;
 }
Exemple #3
0
 public CommentTag(string text, ICommentParser parser, int timeWaitAfterChange = 0)
 {
     Text   = text;
     Parser = parser;
     TimeWaitAfterChange = timeWaitAfterChange;
     Comment             = parser.GetComment(text);
 }
Exemple #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)));
        }
 public DocumentationGenerator(string outputPath, string templatePath, ICommentParser commentParser, EventAggregator eventAggregator)
 {
     _outputPath = outputPath;
     _templatePath = templatePath;
     _commentParser = commentParser;
     _eventAggregator = eventAggregator;
 }
        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>());
 }
        /// <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));
        }
        /// <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));
        }
Exemple #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)));
        }
Exemple #11
0
 public DataTypeBuilder(IEntityNaming naming,
                        ISyntaxGenerator syntax,
                        IExportableCheck exportable,
                        AttachedMemberCache attachedMembers,
                        ICommentParser commentParser)
     : base(naming, syntax, exportable, attachedMembers)
 {
     _commentParser = commentParser;
 }
        /// <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);
        }
Exemple #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));
        }
Exemple #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(),
     });
 }
Exemple #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;
            }
        }
Exemple #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);
        }
Exemple #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;
    }
 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;
 }
Exemple #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);
        }
Exemple #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),
            };
        }
 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;
 }
        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);
        }
Exemple #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)));
 }
Exemple #28
0
 public JavaScriptReferenceParser(ICommentParser commentParser)
     : base(commentParser)
 {
 }
Exemple #29
0
 protected BaseGenerator(ICommentParser commentParser)
 {
     _commentParser = commentParser;
 }
 public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
 {
     return new InlineCode(node.InnerText.TrimComment(first, last));
 }
Exemple #31
0
 public AbConfigParser(ICommentParser commentParser)
 {
     this.commentParser = commentParser;
 }
Exemple #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;
 }
Exemple #33
0
 internal virtual ReferenceParser CreateReferenceParser(ICommentParser commentParser)
 {
     return(new ReferenceParser(commentParser));
 }
Exemple #34
0
 public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
 {
     return new Paragraph(parser.Parse(node.ChildNodes));
 }
 public JavaScriptReferenceParser(ICommentParser commentParser)
     : base(commentParser)
 {
 }
 public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options)
 {
     return(new InlineCode(node.InnerText.TrimComment(true, true)));
 }
 /// <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);
Exemple #38
0
 internal override ReferenceParser CreateReferenceParser(ICommentParser commentParser)
 {
     return(new JavaScriptReferenceParser(commentParser));
 }
 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));
 }
Exemple #41
0
 public PropertyGenerator(
     IDictionary <Identifier, IReferencable> matchedAssociations, ICommentParser commentParser)
     : base(commentParser)
 {
     _matchedAssociations = matchedAssociations;
 }
 /// <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));
 }
Exemple #43
0
 public FieldGenerator( IDictionary<Identifier, IReferencable> matchedAssociations, ICommentParser commentParser )
     : base(commentParser)
 {
     this.matchedAssociations = matchedAssociations;
 }
Exemple #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);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XmlDocumentationParser"/> class.
 /// </summary>
 public XmlDocumentationParser()
 {
     _parser = new CommentParser();
 }
 public IComment Parse(ICommentParser parser, XmlNode node, bool first, bool last)
 {
     return new InlineText(node.InnerText.TrimComment(first, last));
 }