Links in source code snippets?

111 views
Skip to first unread message

Bryan A. Jones

unread,
Feb 27, 2012, 5:51:18 PM2/27/12
to sphin...@googlegroups.com
All,

Is there some way for hilighted source code to include hyperlinks to classes/variables/etc that have been documented? So that

.. function:: foo()

   A function.


::
  foo()  # Would be nice if foo() were hyperlinked in the resulting .html


Bryan
--
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)

TJA

unread,
Apr 30, 2012, 4:19:06 PM4/30/12
to sphin...@googlegroups.com
I would be interested in that as well. If it can't be done automatically: Is there a way to post-process the source-code manually to insert links (in my case, I know all functions and I could easily add the links myself.)

Werner

unread,
Apr 30, 2012, 4:37:51 PM4/30/12
to sphin...@googlegroups.com
On 30/04/2012 22:19, TJA wrote:
I would be interested in that as well. If it can't be done automatically: Is there a way to post-process the source-code manually to insert links (in my case, I know all functions and I could easily add the links myself.)
:func:`foo` should do, see: http://sphinx.pocoo.org/markup/inline.html?highlight=reference

Unless I misunderstand what you and Bryan like to get.

Werner


Am Montag, 27. Februar 2012 23:51:18 UTC+1 schrieb Bryan:
All,

Is there some way for hilighted source code to include hyperlinks to classes/variables/etc that have been documented? So that

.. function:: foo()

   A function.


::
  foo()  # Would be nice if foo() were hyperlinked in the resulting .html


Bryan
--
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)

--
You received this message because you are subscribed to the Google Groups "sphinx-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sphinx-dev/-/KTZ7mxGSp8cJ.
To post to this group, send email to sphin...@googlegroups.com.
To unsubscribe from this group, send email to sphinx-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.

TJA

unread,
May 1, 2012, 9:56:03 AM5/1/12
to sphin...@googlegroups.com
Yeah, with :func:`foo` you can make them in-line in the text. What I'm thinking of is having a code block, and have the links inline there. I.e. similar to the Qt documentation, for instance, here:  http://doc-snapshot.qt-project.org/5.0/qabstractformbuilder.html The first code sample has links inline in it. Can this be done using the docutils API (assuming I know which words to highlight for a given code snippet) or directly when writing reST files?

Cheers,
  -t
To unsubscribe from this group, send email to sphinx-dev+unsubscribe@googlegroups.com.

stephan....@gmail.com

unread,
May 27, 2014, 9:01:00 AM5/27/14
to sphinx...@googlegroups.com, sphin...@googlegroups.com, bjo...@ece.msstate.edu

Hi all,

I know this is an old thread, but I have a very similar need: how can I add :ref: links in highlighted code?

I'm currently evaluating Sphinx as an authoring tool for the manual of a non-Python code library. In highlighted code blocks I would need to link from the calls to the library's functions to the page in the docs where that function is documented. Any idea whether that is possible in Sphinx? It would be similar to the Qt example mentioned in this thread, but the difference is that in my case there's no "autodoc" feature used to document the functions in my library's source.

Thanks in advance for any pointers,

Stephan

Takayuki Shimizukawa

unread,
May 27, 2014, 9:37:39 AM5/27/14
to sphinx...@googlegroups.com, sphin...@googlegroups.com, bjo...@ece.msstate.edu
Hi Stephan,

I think there is no way unless someone extends the code-block
directive or create a new directive. Also I think it is difficult to
achieve without changing the sphinx implementation.

If somebody know a sphinx extension/forked-implementation to achieve
it, please let me know.
I want to try it too :)

Regards,
--
Takayuki SHIMIZUKAWA
http://about.me/shimizukawa
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sphinx-users...@googlegroups.com.
> To post to this group, send email to sphinx...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/d/optout.

Stephan Petersen

unread,
May 28, 2014, 5:40:31 PM5/28/14
to sphinx...@googlegroups.com

Hi Takayuki,

thanks for your reply.

> I think there is no way unless someone extends the code-block
> directive or create a new directive. Also I think it is difficult to
> achieve without changing the sphinx implementation.

Yes, I thought as much :-). I'm currently taking a look at DocBook to
see if that's makes it easier...

Thanks and all the best,

Stephan

Reply all
Reply to author
Forward
0 new messages