Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macros and docstrings #12782

Closed
Keno opened this issue Aug 24, 2015 · 4 comments
Closed

Macros and docstrings #12782

Keno opened this issue Aug 24, 2015 · 4 comments

Comments

@Keno
Copy link
Member

Keno commented Aug 24, 2015

I have some macros that generate types and a few constructors for it. Right now this fails because the doc macro expects a single structure and I don't see a good way to document the type generated by the macro. Would it be reasonable to have docstrings on a block document the first thing in the block. Extremely simplified example:

julia> macro createStruct()
       quote
       type foo
       end
       foo(x::Int) = foo()
       end
       end

julia> """
       Some documentation
       """
       @createStruct
ERROR: Invalid doc expression begin  # none, line 3:
    type #4#foo
    end # line 5:
    #4#foo(#5#x::Int) = begin  # none, line 5:
            #4#foo()
        end
end
@mauro3
Copy link
Contributor

mauro3 commented Aug 24, 2015

Dup of #12705.

@yuyichao
Copy link
Contributor

I think for types, making the type as the return value of the expression should work (at least it used to). Otherwise dup of the other issue.

@mauro3
Copy link
Contributor

mauro3 commented Aug 24, 2015

No, that doesn't work anymore:

julia> macro m()
       quote 
       type A; end
       5
       A
       end
       end

julia> "doc" @m
ERROR: Invalid doc expression begin  # none, line 3:
    type A
    end # line 4:
    5 # line 5:
    A
end

@yuyichao
Copy link
Contributor

No, that doesn't work anymore:

OK. Yeah I haven't been following the discussion there and haven't update my julia for two weeks now ;-p...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants