diff options
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/arch-census.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/arch-census.py b/tools/arch-census.py index ca6d7b8..e6a8300 100755 --- a/tools/arch-census.py +++ b/tools/arch-census.py @@ -48,8 +48,8 @@ TESTS = os.path.join(ROOT, "tests") # A declaration, not a re-export: `pub use` is counted separately as a glob. PUB_RE = re.compile(r"^\s*pub\s+(?:fn|struct|enum|trait|const|static|type)\s+([A-Za-z0-9_]+)") -PUB_CRATE_RE = re.compile(r"^\s*pub\(crate\)\s+(?:fn|struct|enum|trait|const|static|type)\s+", re.M) -GLOB_RE = re.compile(r"^\s*pub(?:\(crate\))?\s+use\s+[^\n]*::\*", re.M) +PUB_CRATE_RE = re.compile(r"^\s*pub\(crate\)\s+(?:fn|struct|enum|trait|const|static|type)\s+") +GLOB_RE = re.compile(r"^\s*pub(?:\(crate\))?\s+use\s+[^\n]*::\*") EDGE_RE = re.compile(r"\bcrate::([a-z_][a-z0-9_]*)") # The binaries are separate crates, so they name the library through its own # name rather than through `crate::`. Those edges are part of the graph too. @@ -130,8 +130,13 @@ def census(): for path, text in src_texts.items(): row = rows[module_of(path)] row["lines"] += text.count("\n") + 1 - row["priv"] += len(PUB_CRATE_RE.findall(text)) - row["glob"] += len(GLOB_RE.findall(text)) + for line in text.splitlines(): + if COMMENT.match(line): + continue + if PUB_CRATE_RE.match(line): + row["priv"] += 1 + if GLOB_RE.match(line): + row["glob"] += 1 size = text.count("\n") + 1 if size > row["largest"]: row["largest"] = size |
