Split up block types of comments in build formats
This commit is contained in:
@@ -71,11 +71,23 @@ COMMENT_STYLE = {
|
||||
nwComment.COMMENT: ComStyle(),
|
||||
nwComment.STORY: ComStyle("Story Structure", "modifier", "note"),
|
||||
}
|
||||
HEADINGS = [
|
||||
COMMENT_TYPE = {
|
||||
nwComment.PLAIN: BlockTyp.COMMENT,
|
||||
nwComment.IGNORE: BlockTyp.COMMENT,
|
||||
nwComment.SYNOPSIS: BlockTyp.SUMMARY,
|
||||
nwComment.SHORT: BlockTyp.SUMMARY,
|
||||
nwComment.NOTE: BlockTyp.NOTE,
|
||||
nwComment.FOOTNOTE: BlockTyp.COMMENT,
|
||||
nwComment.COMMENT: BlockTyp.COMMENT,
|
||||
nwComment.STORY: BlockTyp.NOTE,
|
||||
}
|
||||
HEADING_BLOCKS = [
|
||||
BlockTyp.TITLE, BlockTyp.PART, BlockTyp.HEAD1,
|
||||
BlockTyp.HEAD2, BlockTyp.HEAD3, BlockTyp.HEAD4,
|
||||
]
|
||||
SKIP_INDENT = [*HEADINGS, BlockTyp.SEP, BlockTyp.SKIP]
|
||||
COMMENT_BLOCKS = (BlockTyp.COMMENT, BlockTyp.SUMMARY, BlockTyp.NOTE)
|
||||
META_BLOCKS = (BlockTyp.COMMENT, BlockTyp.SUMMARY, BlockTyp.NOTE, BlockTyp.KEYWORD)
|
||||
SKIP_INDENT = [*HEADING_BLOCKS, BlockTyp.SEP, BlockTyp.SKIP]
|
||||
B_EMPTY: T_Block = (BlockTyp.EMPTY, "", "", [], BlockFmt.NONE)
|
||||
|
||||
|
||||
@@ -619,7 +631,7 @@ class Tokenizer(ABC):
|
||||
bStyle = COMMENT_STYLE[cStyle]
|
||||
tLine, tFmt = self._formatComment(bStyle, cKey, cText)
|
||||
tBlocks.append((
|
||||
BlockTyp.COMMENT, "", tLine, tFmt, tStyle
|
||||
COMMENT_TYPE[cStyle], "", tLine, tFmt, tStyle
|
||||
))
|
||||
|
||||
elif cStyle == nwComment.FOOTNOTE:
|
||||
@@ -990,7 +1002,7 @@ class Tokenizer(ABC):
|
||||
allWordChars += nPWChars
|
||||
textWordChars += nPWChars
|
||||
|
||||
elif tType in HEADINGS:
|
||||
elif tType in HEADING_BLOCKS:
|
||||
titleCount += 1
|
||||
allWords += nWords
|
||||
titleWords += nWords
|
||||
@@ -1004,7 +1016,7 @@ class Tokenizer(ABC):
|
||||
allChars += nChars
|
||||
allWordChars += nWChars
|
||||
|
||||
elif tType in (BlockTyp.COMMENT, BlockTyp.KEYWORD):
|
||||
elif tType in META_BLOCKS:
|
||||
words = tText.split()
|
||||
allWords += len(words)
|
||||
allChars += len(tText)
|
||||
|
||||
Reference in New Issue
Block a user