rtl-aid 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rtl-aid
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: CI-native documentation layer for RTL projects
5
5
  Author: vishwaksen-1
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rtl-aid"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  description = "CI-native documentation layer for RTL projects"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -1,4 +1,4 @@
1
1
  from .core import VerilogWikiParser
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.2.2"
4
4
  __all__ = ["VerilogWikiParser"]
@@ -1,8 +1,15 @@
1
1
  import argparse
2
+ from . import __version__
2
3
  from .core import VerilogWikiParser
3
4
 
4
5
  def main():
5
- parser = argparse.ArgumentParser()
6
+ parser = argparse.ArgumentParser(prog="rtldoc")
7
+
8
+ parser.add_argument(
9
+ "--version",
10
+ action="version",
11
+ version=f"%(prog)s {__version__}"
12
+ )
6
13
 
7
14
  group = parser.add_mutually_exclusive_group(required=True)
8
15
 
@@ -49,9 +56,15 @@ def main():
49
56
  parser.add_argument(
50
57
  "--json-graph",
51
58
  action="store_true",
52
- help="Generate dependency graph as JSON (graph.json) in output directory"
59
+ help="Generate dependency graph as JSON (graph.json)"
53
60
  )
54
-
61
+
62
+ parser.add_argument(
63
+ "--json-graph-dir",
64
+ metavar="DIR",
65
+ help="Directory to write graph.json (only used with --json-graph; default: output directory)"
66
+ )
67
+
55
68
  parser.add_argument(
56
69
  "--exclude",
57
70
  nargs="+",
@@ -74,6 +87,7 @@ def main():
74
87
  verbose=args.v,
75
88
  ci=args.ci,
76
89
  json_graph=args.json_graph,
90
+ json_graph_dir=args.json_graph_dir,
77
91
  print_errors=args.print_errors,
78
92
  exclude=args.exclude,
79
93
  dry_run=args.dry_run,
@@ -52,7 +52,7 @@ def _eval_ast_node(node):
52
52
 
53
53
 
54
54
  class VerilogWikiParser(object):
55
- def __init__(self, paths, verbose=0, ci=False, json_graph=False, print_errors=False, exclude=None, dry_run=False):
55
+ def __init__(self, paths, verbose=0, ci=False, json_graph=False, json_graph_dir=None, print_errors=False, exclude=None, dry_run=False):
56
56
  self.paths = paths
57
57
  self.modules = {}
58
58
  self.called_by = {}
@@ -60,6 +60,7 @@ class VerilogWikiParser(object):
60
60
  self.verbose = verbose
61
61
  self.ci = ci
62
62
  self.json_graph = json_graph
63
+ self.json_graph_dir = json_graph_dir
63
64
  self.print_errors = print_errors
64
65
  self.exclude = exclude or []
65
66
  self.issues = []
@@ -436,9 +437,13 @@ class VerilogWikiParser(object):
436
437
  "called_by": self.called_by.get(m, [])
437
438
  }
438
439
 
439
- path = os.path.join(out_dir, "graph.json")
440
- with open(path, "w") as f:
441
- json.dump(graph, f, indent=2)
440
+ graph_dir = self.json_graph_dir if self.json_graph_dir else out_dir
441
+ if not self.dry_run:
442
+ os.makedirs(graph_dir, exist_ok=True)
443
+ path = os.path.join(graph_dir, "graph.json")
444
+ if not self.dry_run:
445
+ with open(path, "w") as f:
446
+ json.dump(graph, f, indent=2)
442
447
 
443
448
  # -------------------------
444
449
  # CI VALIDATION
@@ -4,6 +4,7 @@ import sys
4
4
  import os
5
5
  import argparse
6
6
  import shutil
7
+ from . import __version__
7
8
 
8
9
 
9
10
  def _get_verilator_version():
@@ -203,6 +204,16 @@ def tag_file(filepath, issues, lint_cmd):
203
204
  new_headers = []
204
205
  if "// lint-test:" not in full_content:
205
206
  new_headers.append(f"// lint-test: {lint_cmd_str}\n")
207
+ else:
208
+ # Update existing lint-test line with the new command
209
+ new_lines = []
210
+ for line in lines[:insert_idx]:
211
+ if line.strip().startswith("// lint-test:"):
212
+ new_lines.append(f"// lint-test: {lint_cmd_str}\n")
213
+ else:
214
+ new_lines.append(line)
215
+ lines = new_lines + lines[insert_idx:]
216
+
206
217
  if "// tb-test:" not in full_content:
207
218
  new_headers.append("// tb-test: tba\n")
208
219
 
@@ -218,6 +229,11 @@ def main():
218
229
  prog="rtllint",
219
230
  description="Run verilator lint on Verilog files and tag warnings inline"
220
231
  )
232
+ parser.add_argument(
233
+ "--version",
234
+ action="version",
235
+ version=f"%(prog)s {__version__}"
236
+ )
221
237
  parser.add_argument(
222
238
  "file",
223
239
  nargs="+",
@@ -255,7 +271,7 @@ def main():
255
271
  print(f"Error: {filepath}: file not found", file=sys.stderr)
256
272
  continue
257
273
 
258
- output, cmd = _run_lint(filepath, args.include_dirs)
274
+ output, _ = _run_lint(filepath, args.include_dirs)
259
275
  issues = parse_lint_output(output, filepath)
260
276
 
261
277
  with open(filepath) as f:
@@ -274,13 +290,19 @@ def main():
274
290
  continue
275
291
 
276
292
  any_issues = True
293
+ # Build rtllint command for tagging
294
+ rtllint_cmd = ["rtllint"]
295
+ for d in args.include_dirs:
296
+ rtllint_cmd.append(f"-I{d}")
297
+ rtllint_cmd.append(filepath)
298
+
277
299
  if args.dry_run:
278
300
  print(f"\n{filepath}: {len(issues)} issue(s) would be tagged:")
279
301
  for ln, (warning_id, msg) in sorted(issues.items()):
280
302
  tag = f"[{warning_id}] " if warning_id else ""
281
303
  print(f" Line {ln}: {tag}{msg}")
282
304
  else:
283
- tag_file(filepath, issues, cmd)
305
+ tag_file(filepath, issues, rtllint_cmd)
284
306
  print(f"{filepath}: tagged {len(issues)} issue(s)")
285
307
 
286
308
  sys.exit(1 if any_issues else 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rtl-aid
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: CI-native documentation layer for RTL projects
5
5
  Author: vishwaksen-1
6
6
  License-Expression: MIT
@@ -3,6 +3,7 @@ from tests.core.test_parsing import * # noqa: F401,F403
3
3
  from tests.core.test_ci import * # noqa: F401,F403
4
4
  from tests.core.test_markdown import * # noqa: F401,F403
5
5
  from tests.core.test_gaps import * # noqa: F401,F403
6
+ from tests.core.test_json_graph_dir import * # noqa: F401,F403
6
7
 
7
8
  if __name__ == "__main__":
8
9
  import unittest
@@ -4,6 +4,7 @@ from tests.lint.test_tag_file import * # noqa: F401,F403
4
4
  from tests.lint.test_include_dirs import * # noqa: F401,F403
5
5
  from tests.lint.test_gaps import * # noqa: F401,F403
6
6
  from tests.lint.test_verilator_integration import * # noqa: F401,F403
7
+ from tests.lint.test_rtllint_command_tagging import * # noqa: F401,F403
7
8
 
8
9
  if __name__ == "__main__":
9
10
  import unittest
File without changes
File without changes
File without changes