slichlyter12 / Postal

A Tool to Automatically Organize the Structure of a Codebase Using Information Foraging Theory Design Patterns
GNU General Public License v3.0
10 stars 1 forks source link

Parser doesn't skip comments #4

Open slichlyter12 opened 7 years ago

slichlyter12 commented 7 years ago

The parser should ignore links (or maybe style them differently) that are commented out in the users code. For example if the user has a list of links but one is commented out, the parser still counts this whereas it should probably be handled differently.

The following example is from kingfish:header.php

<div class="collapse navbar-collapse" id="site-menu">
    <ul class="nav navbar-nav navbar-right" id="site-menu">
    <!-- <li><a href="#">About</a></li> -->
    <li class="menu-button"><a href="menu.php?id=bites">Bites</a></li>
    <li class="menu-button"><a href="menu.php?id=cocktails">Cocktails</a></li>
<!-- <li class="menu-button"><a href="neighborhood.php">Neighborhood</a></li> -->
    </ul>
</div>

Links to "About" and "Neighborhood" should be ignored, but they aren't.

Thecmar7 commented 7 years ago

I don't think it should skip comments. I think styling them differently would be best. The way I see myself using Postal would be for mostly non-HTML projects and I would use the comments as the way of making links. That would be just the simplest for me personally and I think other people would try to use it the same way.

I understand why we would want to skip them though.

slichlyter12 commented 7 years ago

I think we should add in a comments section to the grammars file. The parser behavior will be extremely similar to the "tagged" type. There is also no need for "tagEnd".

Here is an example JSON:

"rules": [{
    "title": "comments",
    "type": "comment",
    "options": {
        "openTag": "<!--",
        "closeTag": "-->",
        "nodeColor": "grey"
    }
}]

We could also have another option which would allow the user to define ignorable comments versus styled comments. Ignored comments would be such things like descriptions of code whereas styled comments could be code that the user commented out but may want to see how it might connect in the future.