jackscodemonkey / sphinx-sql

Autodoc for PG SQL files
GNU General Public License v3.0
15 stars 6 forks source link

return_type attribute for functions #17

Open FilippoTomelleri opened 1 month ago

FilippoTomelleri commented 1 month ago

Hello @jackscodemonkey,

I am using this (really cool) package to document some SQL scripts, but I get a strange error when I try to document an SQL function: AttributeError: 'types.SimpleNamespace' object has no attribute 'return_type'

I had a look in the source code and it seems like the package gives for granted that there should be a _returntype attribute when working with SQL functions.

if core_text.type == "FUNCTION": 
     section += n.line(
           "RETURNS: {}".format(core_text.comments.return_type),
           "RETURNS: {}".format(core_text.comments.return_type),
     )

Adding a check like hasattr(core_text.comments, "return_type") in the if clause seems to work. If you think that I am doing something wrong in my documentation comment, please let me know, thanks!

Kickm3 commented 1 week ago

I had a similar problem and came to the same solution as Filippo. I also had to add another hasattr check to line 445:

if hasattr(core_text.comments, "param") and len(core_text.comments.param) > 1: