MCPcopy
hub / github.com/666ghj/BettaFish / count_charts

Function count_charts

regenerate_latest_html.py:152–169  ·  view source on GitHub ↗

统计整本 Document IR 中的 Chart.js 图表数量。 会遍历每章的 blocks,递归查找 widget 类型中以 `chart.js` 开头的组件,便于快速感知图表规模。 参数: document_ir: 完整的 Document IR 返回: int: 图表总数

(document_ir)

Source from the content-addressed store, hash-verified

150
151
152def count_charts(document_ir):
153 """
154 统计整本 Document IR 中的 Chart.js 图表数量。
155
156 会遍历每章的 blocks,递归查找 widget 类型中以 `chart.js`
157 开头的组件,便于快速感知图表规模。
158
159 参数:
160 document_ir: 完整的 Document IR
161
162 返回:
163 int: 图表总数
164 """
165 chart_count = 0
166 for chapter in document_ir.get("chapters", []):
167 blocks = chapter.get("blocks", [])
168 chart_count += _count_chart_blocks(blocks)
169 return chart_count
170
171
172def _count_chart_blocks(blocks):

Callers 1

stitch_documentFunction · 0.70

Calls 2

_count_chart_blocksFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected