Index

JHSParser

MMO\doc\js · 1 symbol · generated 30 Sep 2026

class

JHSParser

JHSParser.php:26

Extracts documentation from a .jhs file -- mmo.client's one-file format holding an element's markup, its javascript class and its styles together (JHSCompiler).

class MMO\doc\js\JHSParser extends MMO\doc\js\Parser
Namespace
MMO\doc\js
Extends
Parser
A `.jhs` file documents itself in three different places at once, and all three end up on the same page: | where | what it declares | |---|---| | the root tag | the element's tag name (`<mmo-progress>`) or the view's id (`<view id="Issue">`), and every attribute it observes | | the class's jsdoc | `@attr name - text`, `@css class - text`, `@slot name - text`, `@extends Base` (the same tags the compiler's own `documentation()` reads) | | the `<script>` class | the methods, accessors and fields, read by [`Parser`](https://mcp.mmoframework.fr/documentation/mmo.doc/php/js/Parser.md#parser) exactly as in a plain `.js` file | An attribute written bare on the root tag (`<mmo-radio readonly value>`) is a boolean-ish attribute with no default; one written `value="0"` carries its default. Both become [`DocMember::KIND_ATTRIBUTE`](https://mcp.mmoframework.fr/documentation/mmo.doc/php/models/DocMember.md#docmember-kind-attribute) members, merged with whatever the matching `@attr` tag says about them.
$symbols = (new \MMO\doc\js\JHSParser())->parseFile('/path/to/mmo-progress.jhs'); echo $symbols[0]['name'];// 'mmo-progress'

Index

language
parse($source, $filename)
parseScript($script, $filename, $line)Parse one <script> block as javascript, shifting every line number by where the block starts in the .jhs file.
readRootTag($source)Read the file's root tag: its name, its attributes, and where it starts.
readScripts($source)
readSlots($source)
rootSignature($tag, $attributes, $isView)
taggedDescriptions($comment, $tag)Read a @tag name - description family into a name => description map -- the shape @attr, @css and @slot share (JHSCompiler::extractJSDoc, which reads the very same tags).

Properties1

language

protected string $language = 'jhs'
Type
string

Methods7

parse($source, $filename)

JHSParser.php:34
function parse(string $source, string $filename = ''): array
$sourcestringthe .jhs source
$filename = ''string
returnsarraya single symbol -- the element or the view the file declares

parseScript($script, $filename, $line)

JHSParser.php:150

Parse one <script> block as javascript, shifting every line number by where the block starts in the .jhs file.

protected function parseScript(string $script, string $filename, int $line): array
$scriptstring
$filenamestring
$lineintthe 1-based line the block's content starts on
returnsarray

readRootTag($source)

JHSParser.php:168

Read the file's root tag: its name, its attributes, and where it starts.

protected function readRootTag(string $source): array
$sourcestring
returnsarray?string, 1: array<string,?string>, 2: int} the tag name (null when there is none), its attributes (null value for a bare one), and the offset of the <

readScripts($source)

JHSParser.php:190
protected function readScripts(string $source): array
$sourcestring
returnsarraystring, 1: int}> every <script> block's content and the line it starts on

readSlots($source)

JHSParser.php:201
protected function readSlots(string $source): array
$sourcestring
returnsarraythe names of the <slot>s the markup declares ('' for the default one).

rootSignature($tag, $attributes, $isView)

JHSParser.php:234
protected function rootSignature(string $tag, array $attributes, bool $isView): string
$tagstring
$attributesarray
$isViewbool
returnsstringthe root tag as it would be written in a page, attributes included.

taggedDescriptions($comment, $tag)

JHSParser.php:216

Read a @tag name - description family into a name => description map -- the shape @attr, @css and @slot share (JHSCompiler::extractJSDoc, which reads the very same tags).

protected function taggedDescriptions(MMO\doc\helpers\DocComment $comment, string $tag): array
$commentDocComment
$tagstring
returnsarray
Inherited members (51)
PropertiesDeclared byDescription
commentsParser
countParser
filenameParser
providesParser
sourceParser
symbolsParser
tokensParser
MethodsDeclared byDescription
accessorSignature($name, $getter, $setter, $modifiers)Parser
comment($doc)Parser
continuesExpression($i)Parser
endsOpen($i)Parser
examplesOf($comment)Parser
fieldSignature($name, $value, $modifiers)Parser
getProvides()Parser
isArrowHeader($i)Parser
isOpening($i)Parser
lineCommentsDoc($texts, $first, $i, $line, $doc)ParserTurn a kept run of // lines into a doc-comment-shaped token, or give the pending one back when there is nothing worth keeping.
looksLikeConstant($name)Parser
matchBracket($i)Parser
mergeAccessors($members)ParserFold each get x()/set x() pair into the single property it really is, the way a reader thinks of it -- with the getter's own doc comment and @return {T} type (a setter's jsdoc is discarde…
methodSignature($name, $params, $modifiers)Parser
newMember($kind, $name, $comment, $line, $modifiers, $owner)Parser
newSymbol($kind, $name, $doc, $line)Parser
paramTag($comment, $name)Parser
parseAssignment($start, $name, $i, $doc)ParserParse <name> = <value> once the left-hand side is known, and turn the right-hand side into the matching kind of symbol.
parseClass($i, $name, $doc)Parser
parseFile($filename)Parser
parseFunction($i, $name, $doc, $async)Parser
parseMembers($i, $end, $owner)ParserParse a class body or an object literal into members.
parseParam($from, $to, $comment)Parser
parseParams($i, $end, $comment)ParserSplit a parameter list into DocParam, merging in whatever the jsdoc @param tags say about each one.
parseStatement($i, $doc)ParserParse one top-level statement, registering whatever symbol it declares.
readLineComments($i, $doc)ParserCollect a run of consecutive // lines as a doc comment, so constants documented that way are not lost.
readPath($i)ParserRead a dotted path (MMO.core.Map) starting at $i.
reference($name)Parser
register($symbol)ParserRegister a symbol, merging it into a same-named one already found (a class re-opened, a namespace extended).
returnOf($comment)Parser
skipArrowHeader($i)Parser
skipSemicolon($i)Parser
skipStatement($i)Parser
split($name)ParserA symbol declared under an already-known namespace object becomes one of its members instead of a page of its own -- that is what makes MMO.core.strings.bytesize show up on the MMO.core.strings…
statementEnd($i, $limit)ParserFind where a statement (or an object-literal entry) ends: the first ; or , at depth 0, the first token on a new line when nothing is left open (javascript's automatic semicolon insertion), or $…
stringAt($i)Parser
StripBanner($text)ParserDrop the section banners this codebase draws with comments, which would otherwise be read as the documentation of whatever follows them -- and, worse, turn into setext <h1>s once rendered as mark…
tagsOf($comment)ParserEvery doc tag that is not already rendered as a first-class part of the model, kept in source order so the page can show @see, @deprecated, @todo, @since, @author...
tagType($tag)Parser
text($from, $to)Parser
throwsOf($comment)Parser
type($text)ParserBuild a DocType from a jsdoc type expression ({number|string}, {Array<MMO.core.Map>}).
typeAt($i)Parser
value($i)Parser