I have many SCSS files and want to make a style guide (a library with all components like buttons, forms, ...). This style guide should work automatically, so that when you create a new stylesheet it should automatically scan the comments and put the data into an array to create a dynamic information page about the new component.
At example:
/**
* @title title1
* @description description1
* @author author1
*/
.list {
li {
overflow: hidden;
border-bottom: cornflowerblue;
margin: 0 0 4px 0;
}
a {
text-decoration: none;
}
}
Now I want to parse this comment and want to get the word(s) after a.e. the @title Tag. So in this case I would like to get the word "title1" and automatically save it into an array. My try was following:
$source = file_get_contents("mysite/examplestyles.scss");
$tokens = token_get_all($source);
$comment = array(
T_COMMENT,
T_DOC_COMMENT
);
foreach ($tokens as $token)
{
if (!in_array($token[0], $comment))
{
continue;
}
$txt = $token[1];
}
How should I change my code sample to get the informations I would like to have? It would be great if somebody can help me. I think it would be understandable if the ouput is the information I would like to get (title1, description1, author1) so a code sample would be nice to have.
If you have any questions you can ask me.
Thank you!