A simple script that parse a website and analyse BEM usage.
BeautifulSoup4 - See https://pypi.python.org/pypi/beautifulsoup4
python bem_analyzer.py http://www.site.com
This command will print something like this:
Element found without a block: tag-list__item
Multiple element found: article__body__link
Modifier found without its element: tag-list__item--first
3 errors found!
The first error mean that tag-list__item
has no parent called tag-list
.
The second error mean that article__body__link
mustn't have multiple element.
These selectors are good:
- article__body
- article__link
The third error mean tag-list__item--first
must have tag-list__item
in the same class attribut.
Example:
<div class="tag-list__item tag-list__item--first"></div>
Python 2 and Python 3.
Tested with versions 2.7.6 and 3.4.3.