Problems with making sure your inside a DocBlock

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by Martin Lundberg - Sweden
Avatar
Hello once again! (I hope I'm not asking to much questions)

I've got yet another problem, the thing I'm not sure if Im not supposed to ask you this or not. If this is nothing that has to do with SyntaxEditor then just tell me and I'll have to ask somewhere else.

My problem is this:

I want tags in a DocBlock to be highlighted different. A DocBlock is used by a script called phpDocumentor which takes comments out of php files and makes documentation. A Doc block looks like this:

/**
 * Short description
 *
 * Longer description.
 *
 * @author Martin Lundberg
 * @copyright Copyright (c) 2004-2005 Martin Lundberg.
 */
Now. A DocBlock have to be started with /** thats two stars instead of one that a normal multiline comment has. Then every line have to start with a * character or it will be ignored. The comment is ended as a normal multilinecomment.

I know this much: I can create a DocBlockState which has the startscope /** and the endscope */.

But can I somehow make sure every line is started with a * (whitespace are allowed before the * to make it look better)?

Then I can make a new DocBlockTagState which has @ as start scope and Lineterminatormacro as endscope.

The problem is the making sure that the first non-whitespace character on every line is a *.

Hope I've not explained it to bad, thanks in advance for any answer!

Peace out!

Martin Lundberg
Student, Sweden

Comments (6)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Look at our XML comment definition in our C# sample. It's very similar. Instead, we're looking for /// on each line.


Actipro Software Support

Posted 19 years ago by Martin Lundberg - Sweden
Avatar
I still don't get how to make sure that the commented lines start with a star "*", while the startscope is /** and endscope is */.

If I create a state where startscope is /** and endscope */ and then add a Explicit Pattern Group with all the tags in, they get highlightedd even withouth the star.

This is the code which is wrong because it does not check if theres a star as the first chracter on every lines between the start- and endscope.

 <!-- #################### DockBlock State #################### -->
        <State Key="DocBlockState" Token="DocBlockDefaultToken" Style="DocBlockDefaultStyle">
            <Scopes>
                <Scope BracketHighlight="False">
                    <ExplicitPatternGroup Type="StartScope" Token="DocBlockStartToken" Style="DocBlockDefaultStyle" PatternValue="/**" />
                    <ExplicitPatternGroup Type="EndScope" Token="DocBlockEndToken" Style="DocBlockDefaultStyle" PatternValue="*/" />
                </Scope>
            </Scopes>
            <PatternGroups>
                <ExplicitPatternGroup Token="DocBlockTagToken" Style="DocBlockTagStyle">
                    <ExplicitPatterns>
                        @author @copyright @name @since
                    </ExplicitPatterns>
                </ExplicitPatternGroup>
            </PatternGroups>
        </State>
Any ideas? =)

Martin Lundberg
Student, Sweden

Posted 19 years ago by Martin Lundberg - Sweden
Avatar
I made this:

<!-- ==================== DockBlock State ==================== -->
        <State Key="DocBlockState" Token="DocBlockDefaultToken" Style="DocBlockStyle">
            <Scopes>
                <Scope BracketHighlight="False">
                    <ExplicitPatternGroup Type="StartScope" Token="DocBlockStartToken" Style="DocBlockStyle" PatternValue="/**" />
                    <ExplicitPatternGroup Type="EndScope" Token="DocBlockEndToken" Style="DocBlockStyle" PatternValue="*/" />
                </Scope>
            </Scopes>
            <ChildStates>
                <ChildState Key="DocBlockCommentState" />
            </ChildStates>
        </State>
        
        <!-- ==================== DockBlock Comment State ==================== -->
        <State Key="DocBlockCommentState" Token="DocBlockCommentDefaultToken" Style="DocBlockStyle">
            <Scopes>
                <Scope BracketHighlight="False">
                    <RegexPatternGroup Type="StartScope" Token="DocBlockCommentStartToken" Style="DocBlockStyle" PatternValue="{LineTerminatorWhitespaceMacro}* \*" />
                    <RegexPatternGroup Type="EndScope" Token="DocBlockCommentEndToken" Style="DocBlockStyle" PatternValue="{LineTerminatorMacro}" />
                </Scope>
            </Scopes>
            <PatternGroups>
                <ExplicitPatternGroup Token="DocBlockTagToken" Style="DocBlockTagStyle">
                    <ExplicitPatterns>
                        @name @author @copyright @var @access
                        @deprecated @example @ignore @internal @link
                        @see @since @tutorial @version @abstract
                        @deprec @exception @global @param @return
                        @magic @package @static @staticvar @subpackage
                        @throws @todo
                    </ExplicitPatterns>
                </ExplicitPatternGroup>
            </PatternGroups>
        </State>
The tags get highlighted differently but the DocBlock State does not get stopped at */ because all the code after the docblock in my test php file get's highlighted in comment color. This is proberbly because the last line */ is also taken for a docblockcomment instead of the end of the docblock.

[ 12-07-2004: Message edited by: Martin Lundberg ]

Martin Lundberg
Student, Sweden

Posted 19 years ago by Martin Lundberg - Sweden
Avatar
woho! I think I solved it.. I added [^/] to the PatternValue of the DocBlockComment's startscope. It seems to work, but still, please tell me if it can be done in an easier way.

Thanks in advance!

Martin Lundberg
Student, Sweden

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Try this... I think it's pretty thorough:

<State Key="DocBlockState" Token="DocBlockDefaultToken" Style="DocBlockDefaultStyle">
    <!-- Scopes -->
    <Scopes>
        <Scope>
            <ExplicitPatternGroup Type="StartScope" Token="DocBlockStartToken" Style="DocBlockDelimiterStyle" PatternValue="/*" />
            <RegexPatternGroup Type="EndScope" Token="DocBlockEndToken" Style="DocBlockDelimiterStyle" PatternValue="(\*/) | ({LineTerminatorMacro})" />    
        </Scope>
    </Scopes>
    <!-- Patterns Groups -->
    <PatternGroups>
        <RegexPatternGroup Token="DocBlockDelimiterToken" Style="DocBlockDelimiterStyle" PatternValue="\* [^/]" />
        <RegexPatternGroup Token="DocBlockWhitespaceToken" PatternValue="{WhitespaceMacro}+" IsWhitespace="True" />
        <RegexPatternGroup Token="DocBlockLineTerminatorToken" PatternValue="{LineTerminatorMacro}" LookAhead="{WhitespaceMacro}* \*" IsWhitespace="True" />
        <ExplicitPatternGroup Token="DocBlockTagToken" Style="DocBlockTagStyle">
            <ExplicitPatterns>
                @name @author @copyright @var @access
                @deprecated @example @ignore @internal @link
                @see @since @tutorial @version @abstract
                @deprec @exception @global @param @return
                @magic @package @static @staticvar @subpackage
                @throws @todo
            </ExplicitPatterns>
        </ExplicitPatternGroup>
        <RegexPatternGroup Token="DocBlockWordToken" PatternValue="\w+" />
        <RegexPatternGroup Token="DocBlockDefaultToken" PatternValue="[^\*\n]" />
    </PatternGroups>
</State>


Actipro Software Support

Posted 19 years ago by Martin Lundberg - Sweden
Avatar
Yes I worked to and it was alot better then mine ;P

Once again thanks! Now I'm going to IKEA!

Martin Lundberg
Student, Sweden

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.