From 93bf628dc6178674d01255b2b609245605b0aca4 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 28 Nov 2022 23:12:09 +0100 Subject: Added method to get associated comments of an iir node. --- pyGHDL/dom/_Utils.py | 15 +++++++++++++-- 1 file 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 @@ -87,6 +87,17 @@ def GetNameOfNode(node: Iir) -> str: return name_table.Get_Name_Ptr(identifier) +@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`.""" -- cgit v1.2.3