Skip to content

Commit

Permalink
Fix handling of None nodes in GeneratorSnippets
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubAndrysek committed Apr 2, 2024
1 parent 835024b commit 23bc80d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mkdoxy/generatorSnippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ def doxyCode(self, snippet, project: str, config):
if errorMsg:
return errorMsg
node = self.finder.doxyCode(project, config.get("file"))
if node is None:
return self.doxyNodeIsNone(project, config, snippet)

if isinstance(node, Node):
progCode = self.codeStrip(
node.programlisting,
Expand Down Expand Up @@ -268,6 +271,9 @@ def doxyFunction(self, snippet, project: str, config: dict):
return errorMsg

node = self.finder.doxyFunction(project, config.get("name"))
if node is None:
return self.doxyNodeIsNone(project, config, snippet)

if isinstance(node, Node):
self._recurs_setLinkPrefixNode(node, self.pageUrlPrefix + project + "/")
return self.generatorBase[project].function(node, config)
Expand All @@ -288,6 +294,9 @@ def doxyClass(self, snippet, project: str, config: dict):
return errorMsg

node = self.finder.doxyClass(project, config.get("name"))
if node is None:
return self.doxyNodeIsNone(project, config, snippet)

if isinstance(node, Node):
self._recurs_setLinkPrefixNode(node, self.pageUrlPrefix + project + "/")
return self.generatorBase[project].member(node, config)
Expand All @@ -308,6 +317,9 @@ def doxyClassMethod(self, snippet, project: str, config):
return errorMsg

node = self.finder.doxyClassMethod(project, config.get("name"), config.get("method"))
if node is None:
return self.doxyNodeIsNone(project, config, snippet)

if isinstance(node, Node):
self._recurs_setLinkPrefixNode(node, self.pageUrlPrefix + project + "/")
return self.generatorBase[project].function(node, config)
Expand Down Expand Up @@ -363,6 +375,16 @@ def doxyFileList(self, snippet, project: str, config):
return self.generatorBase[project].fileindex(nodes, config)


def doxyNodeIsNone(self, project: str, config: dict, snippet: str) -> str:
return self.doxyError(
project,
config,
"Node is None",
"Node is None",
"yaml",
snippet,
)

### Create documentation generator callbacks END


Expand Down

0 comments on commit 23bc80d

Please sign in to comment.