Literate编程,组织模式,函数声明



我想用组织模式写一个Literate程序。假设我有以下功能:

fn do_stuff()
{
// 200 lines of code go here.
}

我会在组织模式下写这样的东西:

#+BEGIN_SRC rust :tangle /some/path
fn do_stuff()
{
#+END_SRC
// Many more blocks of `BEGIN_SRC` go here to exlpain 200 lines of code mentioned above.
// They will have formatting, and prose between them, and headings with different nesting levels.
// The whole shebang in short.
#+BEGIN_SRC rust :tangle /some/path
}
#+END_SRC

现在,问题来了。我希望我能好好解释,这有点难以用语言表达。我该如何处理上面显示的第一个和最后一个#+BEGIN_SRC块?如何使用组织模式和/或Literate编程设计函数声明的样式?上面提到的200行代码中的所有"格式、散文、标题"似乎都有点不合时宜。

我需要想法,请:-(

提前谢谢。

我会使用noweb来纠缠完整的代码,而不必按顺序显示所有代码。也就是说,我会做这样的事情:

The core code is
#+name: code1
#+begin_src rust :noweb yes :tangle no
...
#+end_src
More code etc. and then, at the end:
#+BEGIN_SRC rust :tangle /some/path
fn do_stuff()
{
<<code1>>
}
#+END_SRC

您可能还需要完整代码块上的:noweb yes

最新更新