emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Include sections of org document in tangled files
@ 2016-12-02 22:05 David Dynerman
  2016-12-03 18:16 ` Charles C. Berry
  0 siblings, 1 reply; 4+ messages in thread
From: David Dynerman @ 2016-12-02 22:05 UTC (permalink / raw)
  To: emacs-orgmode

Dear list,

Is it possible to include sections of an org document while tangling.

I have in mind something like the following:

* Some section
<<doc>>
This is an introduction. We're going to write some code that implements (a finite version of) the formula

\[
f(x) = 1 + x + \frac{x^2}{2} + \frac{x^3}{6} + \ldots + \frac{x^n}{n!} + \ldots
\]

Here's some background about the exponential function.

#+BEGIN_SRC python :tangle myfunction.py
from math import factorial

def f(x,n):
    """<<doc>>"""

    y = 0
    for i in range(n+1):
        y = y + x**i/factorial(i)

    return y
#+END_SRC

The idea would be that when I export this to HTML, I get a nice literate
programming math jax'd section introduction that explains what the
function is doing. Then, when I tangle to generate the python file, the
org section introduction would be included as the python docstring of
the function.

This would be really useful, because currently I find myself repeating
information when I use org for literate programming. First, I explain
what a python function is doing in the org file, but then I also want to
include a docstring in the tangled output that basically contains the
same information as the org file.

Thank you,
David

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-08  3:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-02 22:05 Include sections of org document in tangled files David Dynerman
2016-12-03 18:16 ` Charles C. Berry
2016-12-07 23:46   ` David Dynerman
2016-12-08  3:12     ` Charles C. Berry

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).