在 Windows 上用 Python 进行文学编程的最佳方法是什么? [英] What's the best way to do literate programming in Python on Windows?

查看:32
本文介绍了在 Windows 上用 Python 进行文学编程的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 Python 进行文学编程的各种方法.我喜欢 noweb,但我有两个主要问题使用它:首先,很难在 Windows 上构建,我在 Windows 上花费了大约一半的开发时间;其次,它要求我缩进每一块代码,因为它会出现在最终程序中——我在编写它时不一定知道.我不想用 Leo,因为我非常喜欢 Emacs.

是否有一个很好的识字编程工具:

  1. 在 Windows 上运行
  2. 允许我在使用时设置块的缩进,而不是在写入时设置
  3. 仍然让我在 Emacs 中工作

谢谢!

<小时>

更正:noweb 确实允许我稍后缩进——我误读了我在上面找到的论文.

<块引用><块引用><块引用>

默认情况下,notangle 在扩展块时保留空格并保持缩进.因此,它可以与 Miranda 和 Haskell 等语言一起使用,其中缩进很重要

这让我只剩下在 Windows 上运行"的问题.

解决方案

我是这样做的:

http://sourceforge.net/projects/pywebtool/

您可以获得任意数量的 web/weave 产品,它们将帮助您一次性构建文档和代码.

你可以——很容易——编写自己的.从 RST 源中提取 Python 代码块并对其进行组装并不是一门高深的科学.实际上,我建议您编写自己的 Docutils 指令来从 RST 源文档中组装 Python 代码.

您通过 docutils rst2html(或 Sphinx)运行 RST 以生成最终的 HTML 报告.

您在同一个 RST 源上运行您自己的实用程序来提取 Python 代码块并生成最终模块.

I've been playing with various ways of doing literate programming in Python. I like noweb, but I have two main problems with it: first, it is hard to build on Windows, where I spend about half my development time; and second, it requires me to indent each chunk of code as it will be in the final program --- which I don't necessarily know when I write it. I don't want to use Leo, because I'm very attached to Emacs.

Is there a good literate programming tool that:

  1. Runs on Windows
  2. Allows me to set the indentation of the chunks when they're used, not when they're written
  3. Still lets me work in Emacs

Thanks!


Correction: noweb does allow me to indent later --- I misread the paper I found on it.

By default, notangle preserves whitespace and maintains indentation when expanding chunks. It can therefore be used with languages like Miranda and Haskell, in which indentation is significant

That leaves me with only the "Runs on Windows" problem.

解决方案

I did this:

http://sourceforge.net/projects/pywebtool/

You can get any number of web/weave products that will help you construct a document and code in one swoop.

You can -- pretty easily -- write your own. It's not rocket science to yank the Python code blocks out of RST source and assemble it. Indeed, I suggest you write your own Docutils directives to assemble the Python code from an RST source document.

You run the RST through docutils rst2html (or Sphinx) to produce your final HTML report.

You run your own utility on the same RST source to extract the Python code blocks and produce the final modules.

这篇关于在 Windows 上用 Python 进行文学编程的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆