Ask Your Question
3

Atomatic building of documentation for a custom library

asked 2012-10-31 10:36:59 +0100

Jesustc gravatar image

Hi there,

I have created a .sage file with functions of my own, and have documented every function following http://www.sagemath.org/doc/developer...

Is there a way of generating automatically a pdf or html with the docstring of every function in the library, such as the ones in the sage documentation?

Or, more or less the same: can I use something like 'sage -docbuild' for a custom file (with standard doctrings)?

Cheers!

edit retag flag offensive close merge delete

Comments

Well, it *is* possible if you add your file to your Sage installation (presumably as a .py file?) and then add it to the list of things in the reference manual. But I think you mean as a separate file.

kcrisman gravatar imagekcrisman ( 2012-11-02 10:53:36 +0100 )edit

I do, thanks.

Jesustc gravatar imageJesustc ( 2012-11-02 11:57:02 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-11-01 13:32:07 +0100

I don't think this is possible now, but it's an interesting idea. I wonder how hard it would be to implement.

edit flag offensive delete link more

Comments

I wouldn't imagine it would be that hard, if we could just automate the sphinx quickstart thing to add the files and then do whatever magic extracts the function definitions in Sage's ReST format. I'd be very open to reviewing any work you do on that ;)

kcrisman gravatar imagekcrisman ( 2012-11-02 10:54:48 +0100 )edit
1

I've been playing with it for the last day. I may have something soon. One issue is to decide where to do the building; I think it makes most sense to do everything in the user's .sage directory.

John Palmieri gravatar imageJohn Palmieri ( 2012-11-02 11:17:36 +0100 )edit
1

Shame on me: http://ask.sagemath.org/question/432/using-sphinx-to-document-a-module-using-sage. Still, I would say it is not a perfect solution.

Jesustc gravatar imageJesustc ( 2012-11-02 11:44:08 +0100 )edit

I had a feeling, but was also too lazy... not perfect, but certainly doable.

kcrisman gravatar imagekcrisman ( 2012-11-02 13:47:18 +0100 )edit
2

See also http://trac.sagemath.org/sage_trac/ticket/13679. This works for me with .py and .sage files, but not with .pyx files.

John Palmieri gravatar imageJohn Palmieri ( 2012-11-02 14:28:18 +0100 )edit

That's beyond wonderful! Unfortunately, I have encountered some problems after applying the patch: (1) 'autodoc can't import/find module ...', so where should I put the file?; and (2) the file name contains an underscore, which sphinxs is treating like a math subscript. But, really, thanks for the quick solution! :)

Jesustc gravatar imageJesustc ( 2012-11-04 15:27:36 +0100 )edit

Finally worked: I had to run it from the sage shell, rename the file to a .py (it was .sage) and add the corresponding path to the $PYTHONPATH of the sage shell. Interestingly, a couple of spurious functions that were not in the module did appear in the documentation. Cheers!

Jesustc gravatar imageJesustc ( 2012-11-04 18:14:17 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2012-10-31 10:36:59 +0100

Seen: 396 times

Last updated: Nov 01 '12