aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom/_Utils.py
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2022-11-28 23:12:09 +0100
committerPatrick Lehmann <Patrick.Lehmann@plc2.de>2022-12-23 23:42:29 +0100
commit93bf628dc6178674d01255b2b609245605b0aca4 (patch)
tree0267913d47cdd361932de468adb6b4ef13c25392 /pyGHDL/dom/_Utils.py
parent8845f761ed2299e595afd5eee2444fed7fb79639 (diff)
downloadghdl-93bf628dc6178674d01255b2b609245605b0aca4.tar.gz
ghdl-93bf628dc6178674d01255b2b609245605b0aca4.tar.bz2
ghdl-93bf628dc6178674d01255b2b609245605b0aca4.zip
Added method to get associated comments of an iir node.
Diffstat (limited to 'pyGHDL/dom/_Utils.py')
-rw-r--r--pyGHDL/dom/_Utils.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pyGHDL/dom/_Utils.py b/pyGHDL/dom/_Utils.py
index 0349a11ef..b61168418 100644
--- a/pyGHDL/dom/_Utils.py
+++ b/pyGHDL/dom/_Utils.py
@@ -13,7 +13,7 @@
#
# License:
# ============================================================================
-# Copyright (C) 2019-2021 Tristan Gingold
+# Copyright (C) 2019-2022 Tristan Gingold
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ from pyTooling.Decorators import export
from pyVHDLModel.SyntaxModel import Mode
-from pyGHDL.libghdl import LibGHDLException, name_table, errorout_memory
+from pyGHDL.libghdl import LibGHDLException, name_table, errorout_memory, files_map, file_comments
from pyGHDL.libghdl._types import Iir
from pyGHDL.libghdl.vhdl import nodes, utils
from pyGHDL.libghdl.vhdl.nodes import Null_Iir
@@ -88,6 +88,17 @@ def GetNameOfNode(node: Iir) -> str:
@export
+def GetDocumentationOfNode(node: Iir) -> str:
+ file = files_map.Location_To_File(nodes.Get_Location(node))
+ idx = file_comments.Find_First_Comment(file, node)
+ documentation = ""
+ while idx != file_comments.No_Comment_Index:
+ documentation += file_comments.Get_Comment(file, idx)
+ idx = file_comments.Get_Next_Comment(file, idx)
+
+ return documentation
+
+@export
def GetModeOfNode(node: Iir) -> Mode:
"""Return the mode of a :obj:`node`."""
if node == Null_Iir: