Well, it's a nice approach.

But it has a few cons:

1. Putting text in a source block is not a very natural way. It may disturb the fluidity, both for writing the Org source and reading the exported document(e.g. html);
2. The bug Eric just found while putting a <<...>> link within quotes, although, it may be easy to fix. 


Greetings.

ZHUO QL (KDr2, http://kdr2.com)



On Monday, May 14, 2018, 11:06:34 PM GMT+8, John Kitchin <jkitchin@andrew.cmu.edu> wrote:


It seems like this is nearly all possible already (see below). It is a little wonky that you have to put text in a src txt block to achieve it, but otherwise what is missing?

* Main document

See [[id:BAD97113-3561-4A4A-BA07-0CD5BF6BA35F][There is a reason we only support two args]] (text to text) for notes about this function. The addition is done in line [[(add)]] (text to code).

#+NAME: DOC-OF-ADD
#+BEGIN_SRC txt
"We use the function add to calculate the sum of two numbers."
#+END_SRC

#+NAME: ADD
#+BEGIN_SRC emacs-lisp -n -r :noweb yes :tangle test.el
(defun add (x y)
  <<DOC-OF-ADD>> ;; code to code
  ;; [[id:BAD97113-3561-4A4A-BA07-0CD5BF6BA35F][There is a reason we only support two args]] code to text
  (+ x y) (ref:add)
  )
#+END_SRC

#+RESULTS: ADD
: add


** Notes

*** There is a reason we only support two args
    :PROPERTIES:
    :ID:       BAD97113-3561-4A4A-BA07-0CD5BF6BA35F
    :END:


John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803