Hello, this is Edward Ream 令德华 亲,这儿是 Edward Ream 令德华
speaking from Madison, Wisconsin. 在米国威斯康星州,麦迪逊 的家里
I wish my friends and colleagues in China all the best. 祝福所有中国的朋友们一切安好
Mr. Zoom.Quiet 周琦 你们的大妈, Zoom.Quiet
has already made important contributions to Leo. 为Leo 作出了一些贡献
具体是什么 你懂的;-)
I invite you all to learn about Leo 现在请大家学习一点儿 Leo
and to make your own contributions. 并作点儿力所能及的贡献
This screencast is intended primarily for Python programmers. 当前截屏主要针对Python程序员
It briefly introduces Leo's programming and scripting features. 简要展示了Leo编程相关的特性
The outline you see is the Leo file I use to develop Leo itself. 当前Leo 文件包含的提纲,正是俺用来进行Leo 自身开发的
It contains over one million lines of Python code 包含了超过一百万行Py代码(真的徦的?!)
and all of Leo's documentation. 以及所有 Leo 的文档
This tab contains the sources for Leo's core. 这个标签包含了所有 Leo 的核心代码
This tab contains the sources for all of Leo's official plugins. 这个呢,包含了所有 Leo 官方插件的代码
This tab contains notes to myself. 这个标签,包含了俺自个儿的笔记
And this tab contains the sources for all of Leo's documentation. 就个则包含了所有文档的源文本
Focusing attention on just the code of interest 聚焦当前代码
makes programming much easier. 进行编程很轻松
Leo's clones are "live" copies of nodes. Leo 的"克隆"是对节点的"活"复制
Changing a clone changes all the copies. 改变任一已克隆节点,能立即同步到所有
Here are some of the clones I created recently 这儿就是刚刚创建的几个 克隆 节点
to improve Leo's find command. Leo 的查找命令很给力
Searching for s_ctrl limits the search to just those clones. 搜索 s_ctrl 能限定只在克隆的节点中
I can also use the clone-find-all command to find all nodes containing s_ctrl. 当然可以使用 clone-find-all 命令搜查所有 包含 s_ctrl 的节点
Now let's look at Leo's scripting features. 现在演示 Leo 的脚本能力
Any Leo node may contain a Python script. 所有Leo 节点都能包含 Python 脚本
Ctrl-B, Leo's execute-script command, Ctrl-B 是Leo 的脚本运行命令,
executes the text of any node or tree as a Python script. 能视当前节点的文本为Python 代码来运行
No special markup is needed. 不用任何特殊标签声明
Here is the famous "hello world" script. 这是著名的 "hello world" 脚本
I'll type Ctrl-B to execute it. 按 Ctrl-B 运行之
Notice that the script runs without errors even though "g" does not seem to be defined. 注意运行出错了 目测是 "g" 未定义
That's because execute-script pre-defines three symbols: g, c and p. 因为试图使用 g, c, p 三个未定义符号
These variables give access to all outline data 这堆变量能访问所有提纲数据
and to all of Leo's own source code. 以及所有 Leo 自身的源代码
You can also build scripts from entire outlines. 你同样能构建针对整个提纲的脚本
Simple markup 简单标记 (section references and @others)节声明和 @所有以下
tells Leo how to build the script. 告诉Leo 如何进行脚本构建
Let's look at an example. 让我们看个实例
Here is the top-level node of a complex script. 这个顶级节点包含了完整的脚本
It starts with a docstring. 以文档字串开始
The next line is a section reference. 紧接的一行就是 节声明
The value of that section reference 节声明中的值
is the contents of a node having that same name. 其实包含了同名节点的所有内容
Next, the script has an @others directive. 接着, 脚本使用了 @others 指令
The value of @others is the contents of all other nodes. @others 则包含了其下所有节点的内容
In this case, the value of @others 当前, @others 的值
is this node and all its descendants. 是这一节点以及子孙节点的所有
Outlines can build external files as well as scripts. 提纲能很好的输出外部脚本文件
leoFind.py is a clone of one of the source files in Leo's core. leoFind.py 是Leo 一个核心源代码的的克隆
It is organized in much the same way. 使用相同模式组织
There is a section reference containing a large amount of documentation... 这个节声明包含了大量的文档...
followed by an @others directive... 追随在 @others 指令中
which pulls in the rest of the tree. 将从子树中同步出来
Notice that more than one node may have an @others directive. 注意不止一个节点中包含 @others 指令
This allows precise control over placement and indentation of source code, 这令源代码的组织超越了缩进的限制
something that is essential for Python programming. 尽管缩进对我蠎行者而言是必不可少的
The previous examples show that outline structure is visible everywhere. 这个例子将展示提纲结构如何应用在任何场景的
Less obviously, but more importantly... 这儿有点儿隐密,但重要的是...
outlines create user-defined contexts and types. 提纲创建了用户定义的内容以及类型
Scripts and programs can use those contexts in new and creative ways. 脚本或代码从而用全新的行为组织
By convention, headlines starting with the @ sign denote new types or contexts. 依例,头一行使用 @符号 指定类型或内 容
Leo defines many types; you can easily define your own. Leo 已定义了很多类型; 你能轻松定义你自个儿的
Let's look at some examples. 哪,再来看些例子
Within an @settings tree... 在一个 @settings 树中
@int, @string and similar nodes define user settings. @int, @string 什么的都是用户定义
These nodes have no effect outside @settings trees. 这些节点不会作用于 @setting 树之外
Here is a clone of the actual settings in this .leo file. 这其实是真实作用的配置文件的 .leo 文件克隆
It contains only the overrides I use in this file. 仅包含了俺的修订
The defaults are set in another .leo file. 而默认值则包含在另外一个 .leo 文件
@test nodes define unit tests. @test 节点定义集成测试
There is no need to subclass unittest.TestCase, 不用 unittest.TestCase 子类
nor is there any need to put your test code within such subclasses. 没有什么需要特殊处理的
Here is a complete unit test. 这就是一个完备的测试案例
Of course, it will fail. 当然的它失败了
Several Leo commands will execute this unit test. 有一系列 Leo 命令可以执行测试
We can see those commands using typing completion. 在提示中可以看到所有命令
Here are the possibilities... 这是能作的...
If we run the unit tests with one of those commands... 如果使用那些命令来运行测试
we'll get this result in the console. 就能在控制台看到结果
As expected, the test fails. 正如所料,测试失败了
Here is another complete unit test. 这是另一个完整的测试案例
It verifies that Leo pre-defines three symbols during unit tests just as in scripts. 检验 Leo 预定义的三种符号能以脚本形式使 用
If we run this test, the test passes. 如果我们运行测试, 是通过的
@button nodes define new Leo commands and also create buttons in the icon area. @button 节点定义新Leo 命令并在图标栏创建按钮
That's how these buttons were defined. 那些是定义过的按钮
You can apply these new commands to any particular tree. 你能让新命令作用于任意节点上
For instance, this button prints the headline of the selected node. 举个栗子 这个按钮打印选中的提纲节点
So let's select a node... 先选中一个节点
and now we'll press this button... 再点击这个按钮
and we see the correct result. 就见到了当前结果
We can also execute the command from the mini-buffer. 我们也能直接在迷你缓冲区中执行命令
All part of Leo are aware of outline structure. Leo 所有方面都受益于提纲式结构
For example, you define abbreviations in @settings trees as usual. 例如,在 @settings 树中配置缩写
I like the end abbreviations with two semicolons so they don't trigger unexpectedly. 我习惯使用两个分号来结束缩写以免意外触发
Abbreviations can expand to text... 缩写也能扩展到文本...
or they can expand to outlines... 或是扩展为提纲...
Leo uses types to determine how particular nodes are rendered. Leo 使用节点类型来约定渲染形式
Alt-0, Leo's vr-toggle command, shows and hides the view- rendered pane. Alt-0 是Leo 的 vr-toggle 命令,控制渲染窗格是否显示
This pane renders the body text of the selected node. 此窗格渲染选中的节点内容
Let's play some music... 让我们播放一些音乐...
By default, the view-rendered pane shows reStructuredText. 默认的,视图-渲染 窗格显示新结构化文本
Depending on types, you can show other kinds of output. 嘦定义类型,你可以展示各种输出效果
Here is an icon... 就是图标...
Here is HTML... 这是 HTML ...
This is the same page rendered differently... 相同的页面渲染出不同效果...
And here is the rendering of an SVG graphics file... 也能渲染 SVG 图形文件...
Here is the rendering of the actual sources. 对当前源代码的渲染
Thanks for watching this video. 以上,感谢大家的观看
Have a great time at your Python conference. 享受你们的 Python大会
Please feel free to contact me at any time. 随时能联系俺
Bye bye...