• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 41, 文章 - 8, 評論 - 8, 引用 - 0
            數據加載中……

            [Python] Leo Tutorial 翻譯

            The Leo Tutorial

            Leo is a power tool for people who want to organize, study and work with data, especially complex data like computer programs, books, web sites and data bases. Superficially, Leo may look like other outlining programs, code folding editors or class browsers, but it most certainly is not.

            Leo 是一個強大的工具,適用于下面的人:希望組織, 管理,研究和處理數據,特別是復雜的數據, 像計算機程序,書籍,網頁以及數據庫。 表面上看, Leo 像其他 outline 的程序, 代碼折疊編輯器或類瀏覽器,但是事實上,它并不是。

            People say Leo is a revolutionary tool, and that Leo is fun to use, even additive. There is a unique “Leo way” of managing data; the term Leonine describes how people treat data in “the world according to Leo”. Leo definitely takes a bit of work to understand. Leo’s users speak of an “Aha” moment, when they see how these pieces fit together: outline structure is significant everywhere. For a more detailed introduction to Leo, see Leo in a nutshell.

            人們說 Leo 是一個革命性的工具,而且 Leo 用起來很有趣, 而且還有甚者。管理書籍有 Leo 式的方法;單詞 Leonine 描述了人么如何在 Leo 的世界中管理數據。 Leo 毫無疑問需要慢慢理解。當 Leo 的用戶看到了一些片段,他們會說出“Aha”: outline 結構在任何地方都很有意義。具體介紹 Leo 請參考 Leo in a nutshell

            Leo is freely available in source or binary form for all major platforms. You may download Leo from http://sourceforge.net/projects/leo/files/Leo/ Leo is Open Software and may be freely distributed.

            Leo 無論源代碼或是二進制程序都是免費的,而且支持大多數的平臺。 你可以從 http://sourceforge.net/projects/leo/files/Leo/ 下載 Leo。 Leo 是開源軟件,而且可以免費發行。

            Leo’s home page contains additional documentation and links to other resources. For another introduction to Leo, open the file quickstart.leo in the leo/doc folder.

            Leo’s home page 包含了額外的文檔和鏈接。 關于 Leo 另外的介紹,打開在 leo/doc 目錄中的 quickstart.leo 進行查看。

            This tutorial introduces the reader to the basic concepts and features of Leo. It helps to have Leo running for hands-on experience, but all examples here are self-contained, so the tutorial can be read off-line as well. See Leo’s Installation Guide. for detailed installation instructions. If you have problems installing Leo, please ask for help on Leo’s forum.

            本教程將介紹 Leo 基本的概念和特性。 它幫助你快速的將 Leo 運行起來,所有的例子也是包含于安裝包中, 所以你可以離線的閱讀。關于安裝具體請看 Leo’s Installation Guide 。 如果你在安裝中碰到了困難,請在 Leo’s forum 中尋求幫助。

            This tutorial does not attempt to be comprehensive and cover every single feature of Leo, or even every commonly used feature. Instead, it introduces many of Leo’s most noteworthy features, and will give you a good idea of Leo’s flavor and style. After reading it, you will be able to use Leo in basic ways to create external files, organize data and run simple scripts. You will then be ready to learn more about Leo’s many advanced features.

            這篇教程并不打算很全面的涉及 Leo 的每個特性,或者甚至是最常用的特性。 相反,它僅僅介紹很多值得注意的特性,并讓你對 Leo 有相應的想法,比如它的流派和風格。 在閱讀完它之后,你將會用 Leo 創建外部文件,組織數據以及運行簡單的腳本。 然后你就會打算學習更多關于 Leo 的高級特性。

            The Glossary is also worth reading.

            Glossary 也是很值得一讀。

            Leo’s main window

            Let’s start looking at Leo in detail. We’ll start with what you see when you first open Leo, Leo’s main window. Leo’s main window, shown below, represents an entire project. As you can see, the main window contains three panes: the outline pane at the top left, the log pane at the top right, and the body pane at the bottom. The window also contains an icon area at the very top, a status area and a mini-buffer at the very bottom.

            讓我們更詳細的看看 Leo 。我們將從你一打開 Leo 的地方開始講解。 Leo 的主窗口。 Leo 的主窗口,像下面顯示的,代表了一個完整的項目。 正如你見到的,主窗口包含了三個面板:左上方的 outline pane , 右上方的 log pane ,以及底部的 body pane 。 當然,窗口中還包含了很頂部的 icon area ,底部的 status areamini-buffer

            leoMainWindow

            Outline pane

            The outline pane shows your project as an outline. The outline contains all your project’s data. An outline consists of nodes. The icon box is a small icon directly to the left of the headline text. The border of the icon box is black if the node has been changed. Smaller icons within the icon box indicate the status of the node:

            Outline pane 將你的項目以提綱的形式顯示。 outline 中包含了所有你項目的數據。一個 outline 包含 node 。 而 icon box 是一個緊挨著標題的小的圖標。 如果節點中的內容有改變,那么這個的邊框就變為黑色的。 而里面更小的圖標指示了節點的狀態:

            A small blue box:   the node has body text.
            A red vertical bar: the node is marked.
            A circular arrow:   the node is cloned.
            一個藍色的盒子: 節點的 body 中包含了文字。
            一個垂直的紅棒: 節點被標記了。
            一個圓形的箭頭: 節點被 clone 了。

            If a node contains children, a smaller icon appears to the left of the icon box. This icon contains a ‘+’ or ‘-‘ symbol. Clicking this expansion box expands or contracts the node.

            如果一個節點包含了子節點,一個更小的圖標將在這個的左邊顯示。 圖標中包含了以后 ‘+’ 或 ‘-‘ 這樣的符號。 點擊這個符號就將這個節點展開或閉合。

            Node

            Each outline node has two two parts, a headline and body text. The outline pane shows headlines. Selecting a headline selects the entire node; the node’s body text appears in the body pane. Leo uses standard terminology to describe the relationships of nodes in an outline. We speak of parent nodes, child nodes, ancestor nodes and descendant nodes.

            每個節點有兩個部分,一個 headlinebody text 。 而 outline pane 中顯示 headline 。選擇一個 headline 就選擇了一整個節點; 節點的 body text 部分會顯示在 body pane 中。 Leo 使用標準的術語來描述節點的關系。 我們會說 parent 節點, child 節點, ancestor 節點和 descendant 節點。

            Body pane

            The body pane contains the body text of the node selected in the outline pane.

            Body pane 包含了被選定的節點的內容。

            Log pane

            The log pane contains informational messages from Leo or your scripts.

            Log pane 中包含從 Leo 或你的腳本中來的信息。

            Icon area

            Depending on what plugins are enabled, the icon area may contain buttons and other widgets that extend what Leo can do. The scripting plugin makes it easy to add buttons to the icon area.

            根據插件的激活情況,此處將會包含不同的按鈕和其他的部件,用于擴展 Leo 。 scripting plugin 可以很方便的將按鈕放到 icon area 中。

            Status area

            The status area shows the line and column containing the body text’s cursor, and the UNL (Uniform Node Location), the path from the top of the outline to the selected node. This path will change as you change outline nodes.

            Status area 顯示光標所在行和列,以及 UNL (Uniform Node Location), 從頂層節點到當前節點的路徑。這個路徑將隨著你的選擇而改變。

            Minibuffer

            You can type command and search strings in the minibuffer. It works much like the Emacs mini-buffer. To enter a command, type <Alt-x> followed by the command name and then <return>. To type a search string, type <ctrl-f> followed by the search string and then <return>. For full details, see Using Leo’s Commands.

            你可以在 minibuffer 中輸入命令以及搜索的字符串。 這個和 Emacs 中的 mini-buffer 非常相似。 為了輸入一個命令,輸入 <Alt-x> 然后后面輸入命令的名稱, 然后輸入 <return> 。為了搜索字符串,輸入 <ctrl-f> 然后輸入要搜索的路徑并按 <return> 。 具體的請參考 Using Leo’s Commands

            External files and @file nodes

            Leo stores outline data on your file system in .leo files. The format of these files is XML. You don’t have to store all your data in .leo files: Leo allows you to store parts of your outline data external files, that is, other files on your file system.

            Leo 將 outline 的數據 以 .leo 存在你的文件系統中。 這些文件的格式是 XML 。你不需要把你全部的數據全部存在 .leo 文件中: Leo 允許你將 outline 中的部分數據以 external file 的形式保存。

            @file nodes create external files. @file nodes have headlines starting with @file followed by a file name. Some examples:

            @file node 將創建外部的文件。 @file 節點的 headline 以 @file 開頭, 然后跟著一個文件名。后面是一些例子:

            @file leoNodes.py
            @file ../../notes.text

            The file name can be an absolute path or a relative path to the file that starts at Leo’s load directory, the directory containing the .leo file.

            文件名可以是絕對路徑或者是相對路徑(以當前載入 leo 文件的路徑開始)。

            Leo reads and writes external files automatically when you open or save your Leo outline:

            Leo 將會自動地讀取和寫入 external file,當你打開或保存 Leo 的 outline:

            • When you open an outline (.leo file) Leo reads all the external files created by the @file nodes in the outline. If you have changed an external file outside of Leo, Leo will update the corresponding @file tree to reflect those changes when Leo next opens the outline.

              當你打開一個 outline (.leo 文件) Leo 將會讀取所有被 @file 節點創建的 external 文件。如果你在 Leo 外改變了一個 external 文件, Leo 在下一次打開 outline 時, 將會更新相應的 @file 節點。

            • When you save your outline, Leo writes all dirty @file nodes. An @file is dirty if the node or any of its descendant nodes has changed. Important: When Leo writes an external file, Leo writes all the essential information in the @file tree to the external file, not to the .leo file. The only nodes that gets written to the .leo file are nodes that are not contained in any @file tree.

              當你保存 outline 時, Leo 會寫入所有的 dirty @file 節點。 當一個節點或任何相應的子節點改變時,這個 @file 就是 dirty 的。 重要 :當 Leo 寫一個 exteranl 文件, Leo 會寫入所有重要的信息, 尤其是 @file 樹中的信息到外部文件中,而 不是 到 .leo 文件中。 只有那些不包含 @file 的節點才被寫入到 .leo 中。

            Creating external files from outlines

            We come now to one of Leo’s most important and unusual features. When Leo writes an external file, it does so in a flexible manner, directed by outline-based markup. This markup tells Leo exactly how to create the external file from an @file node.

            我們現在來見見 Leo 中很重要而不尋常的特性。 當 Leo 向一個 external 的文件寫入東西時, Leo 會通過 outline-based markup 的指令, 進行合適配置。這個標記會準確的告訴 Leo 如果從一個 @file 節點創建 external 文件。

            The obvious way to write an external file would be to write the @file node itself followed by all the descendant nodes in outline order (the order in which nodes appear in the outline). But Leo does not write external files exactly this way.

            最明顯的方式,就是根據子節點的 outline 順序 對 @file 節點進行寫入。但是 Leo 并不是完全按照這種方式進行。

            Yes, Leo does indeed start by writing the @file node itself. But Leo writes the @file node’s descendants only when it sees one of three kinds of Leo markup: section references, the @others directive and the @all directive. We’ll discuss these three kinds of markup in the next section.

            是的, Leo 的確從寫入 @file 節點開始。但是對于 Leo , 只有它見到了相應的指令,才會將 @file 節點的子節點的內容寫入。 有三個這樣的指令: section reference@other 指令 , 以及 @all 指令 。我們將在后面對這些標記進行討論。

            Section references and the @others and @all directives tell Leo to write the expansion of one or more descendant nodes to the external file. Programmers will recognize this process as akin to macro expansion. The following sections will explain this process in detail.

            Section reference , @others 和 @all 指令告訴 Leo 將子節點 擴展 到 external 文件中。 程序員會知道這個宏擴展很像。下面的篇幅就將討論這些。

            Section references

            A section reference is a line of body text of the form:

            一個 section reference 就是在 body text 中有下列形式:

            << a section name >>

            Here, “a section name” can be any descriptive text not containing “>>”. When Leo encounters a section reference, Leo searches all the descendants of the node containing the reference looking for a node whose headline matches the section reference. That is, Leo looks for a descendant node whose headline starts with:

            此處, "a section name" 可以是任何文字,但不包括 “>>” 。 當 Leo 碰到一個 section reference , Leo 會搜索所有的子節點, 然后去匹配在 headline 中有相同內容的引用。 也就是, Leo 會搜索下面的 headline :

            << a section name >>

            We call such nodes named nodes. Leo doesn’t require an exact match. Leo ignores whitespace and the case of letters when comparing headlines to section reference. Also, Leo ignores anything that may follow the section name in a named node. For example, the following headline will match the section reference above:

            我們稱這些節點為 named node 。Leo 不需要完全的匹配。 它會忽略空格和大小寫。同樣, Leo 會忽略在此之后的內容。 比如,下面的 headline 也是可以被匹配的:

            << A Section Name >> (to do)

            If Leo does find a match, Leo replaces the section reference (“<< a section name>>”) by the expansion of the body text of the matched node. That is, Leo replaces the section reference by the body text of the matched node, but Leo expands all markup in the matched node before making the replacement. The entire expansion of the matched node replaces the original section reference. Programmers will recognize this process as recursive macro expansion.

            如果 Leo 的確找到了一個匹配,Leo 會 替換 這個 section reference (”<< a section name>>”),并把 named node 的內容擴展進來。 也就是, Leo 會把匹配的節點的 body text 替換到這里, 但是 Leo 在進行替換前,會先對所有的標記進行擴展。 這樣,原始的 section reference 就被真正的內容替換了。 程序員就會想到這就是遞歸的宏擴展。

            We have just discussed what happens if Leo does find a descendant named node that matches the section reference. If no such match is found the section reference is said to be undefined and Leo does not write any data to the external file. This is not a serious error: Leo will will save the erroneous @<file> tree in the .leo file instead of the external file. No information is lost. By the way, Leo’s syntax coloring will indicate undefined section reference by underlining the section name.

            我們剛討論了如果 Leo 發現一個子的 named node 之后會發生的事情。 如果沒有找到這樣的,那么這個 section reference 就被認為是 undefined 而且 Leo 也不會向 external 文件中寫入任何東西。 這不是一個很嚴重的錯誤: Leo 會把這些寫入到 .leo 文件中, 而不是 external 文件中。沒有任何信息會被丟掉。 順便說下, Leo 的語法加色會指示這個是未定義的引用, 通過加一個下劃線。

            Important: the indentation of section references matters. When expanding a section reference, Leo indents every line of the expansion by the leading whitespace that occurs before the section reference. Note also that you can’t write something after a section reference and expect it to end up on the same line after expansion–Leo always writes a newline after the expansion.

            重要 :section reference 的縮進是有意義的。 當進行擴展時,被擴充的內容前面都會加入空格。 而且注意,你不能往 section reference 后寫入東西并指望這些會出現在每行的末尾。 Leo 在擴展后總會插入一個新行。

            The @others directive

            The @others directive is the second (and most common) way of including descendant nodes in an external files. When Leo encounters the @others directive it replaces the @others directive by the expansion of all unnamed descendant nodes. As with section references, Leo replaces all markup in the descendant nodes, and the entire expansion replaces the @others directive.

            @others directive 是第二個(而且是最常用的)方式, 對子節點進行包含。當 Leo 碰到 @others 指令時, 它會把所有 unamed 的子節點都包含進來。 和 section reference 一樣, Leo 會替換所有的標記, 然后擴展完后的才會去替換 @others 指令。

            In short, section references write named nodes; @others directives write all unnamed nodes. By the way, no node may contain more than one @others directive because there would be no way to “apportion” descendant nodes to more than one @others directive. However, nodes may contain as many section references as you like.

            簡而言之, section reference 會寫入 named 節點; 而 @others 指令則會寫入 unnamed 節點。 順便說下,沒有節點可以包含超過一個的 @others 指令。 因為沒法將這些子節點分配給多個 @others 指令。 但是,節點中可以包含很多的 section reference 。

            As with section references, the indentation of the @others directive matters. This allows Leo to handle Python source code properly. For example, the following is a common way of representing a Python class:

            和 section reference 一樣, @others 指令的縮進也是有意義的。 這就允許 Leo 可以正確的處理 Python 的源代碼。 比如,下面一個是表示 Python 類最常用的方式:

            class myClass:
                '''a docstring'''
                @others

            When Leo writes this node to an external file, Leo will write the first two lines to the external file, with the indentation in effect for the node. Leo will then write all descendant nodes to the external files, with additional indentation equal to the leading whitespace appearing before the @others directive.

            當 Leo 把這個節點寫入一個 external 文件時, Leo 會把頭兩行先寫入 external 文件,而且縮進也會影響節點。 Leo 然后就把所有的子節點寫入,然后會在替換出的內容前再加上額外的空白。

            The @all directive

            The @all directive is the third, simplest (and least common) way of including descendant nodes. This directive causes Leo to write all descendant nodes in outline order, regardless of whether they are named or not. Furthermore, the @all directive does not expand any markup in descendant nodes. This results in Leo writing the external file in the “obvious” way. That is, Leo writes all descendant nodes in outline order.

            而 @all 指令是第三個,最簡單(最不常用)的方式來包含子節點。 這個指令會讓 Leo 以 outline 的順序寫入所有的子節點,而不管節點是否命名。 此外, @all 指令不會對子節點中的任何標記進行擴展。 這個就使得 Leo 以最直接的方式寫入 external 文件。 Leo 會以 outline 的順序寫入所有的子節點。

            Use the all directive if your external file contains unrelated nodes. For example, I use an external file to store programming notes. These notes typically contain snippets of programming source code, but there is no real relationships between the snippets–the file is simply a grab bag of information. The @all directive is designed for this situation.

            如果你的 external 文件包含了無關的節點,那么可以用這個指令。 比如,我用一個 external 文件保存編程的筆記。 這些筆記包含了代碼中的一些片段,而在這些片段之間并無聯系。 這些文件僅僅就是存放信息的袋子而已。 @all 指令就是為這種情況設計的。

            Choosing between @others and sections

            Newcomers to Leo frequently ask when to use the @others directive and when to use sections. It is good style to use section references only when the order of text within a external file matters. For example, Python programmers put docstrings and imports at the start of files. So the body text of @file nodes typically look something like this:

            Leo 的新手經常會問到,什么時候使用 @others 指令而什么時候用 section 。 在涉及內容的順序時,使用 section reference 是比較好的。 比如, Python 程序員一般會把 docstring 和 模塊導入放在 文件的開頭。 所以, @file 節點中的 body text 經常看起來像這樣:

            << docstring >>
            \@language python
            \@tabwidth -4
            << imports >>
            @others

            This ensures that the docstring is first in the file, followed by imports, followed by everything else. Note that the order in which functions are defined in a file, or methods defined within a class, typically does not matter. Thus, it is good style to define classes like this:

            這就保證了 docstring 是在文件的最開始,然后再是模塊導入, 而后又是其他任何東西。注意,在文件中函數的定義, 方法在類體內的定義的順序是無關的。因此, 下面的定義類的方式是比較好的習慣:

            class myClass:
                  << class attributes >>
                  @others

            It would be bad style to define a class like this:

            而下面的則不是很好:

            class myClass:
                  << class attributes >>
                  << method 1 >>
                  << method 2 >>
                  ...

            Not only does this over-specify the order in which methods are defined, but it requires lots of extra typing. Not only must you add a line for each method, but headlines must contain section names such as << method 1 >>, <<method 2>>, etc. When using @others it is good style simply to put the name of each method in the headline.

            不僅僅因為這過分特化了方法在類中的順序,而且這也需要大量額外的輸入。 你不僅需要為每個方法添加這樣的一行,而且在 headline 中也需要包含像 << method 1 >> , << method 2 >> 這樣的東西。 而使用 @others 就大大簡化了要把方法放在 headline 中這樣的事情。

            Organizing programs as outlines

            A few more words about style:

            更多關于風格:

            • It is good style to put each class, function or method in its own node. This makes it easy to see the shape of your code.

              最好把每個類,函數或方法放在自己的節點中。這樣就利于看清楚你代碼的結構。

            • It is good style to use organizer nodes to group related functions or methods. An organizer node has no content except maybe for comments. Like this:

              把相關的函數或方法分組也是很好的習慣。 一個所謂的 organizer 節點除了用于注釋,就可以沒有其他用處了。 像這樣:

              + myClass
                  + birth and death
                      + __init__
                      etc.
                  + getters
                      etc.
                  + setters
                      etc.
                  + misc methods
                      etc.

              (In this notation, ‘+’ denotes a headline.) This organization is far superior to using hideous comments like:

              (在這個記法中, ‘+’ 表示一個 headline 。) 這樣的組織比那種隱式的注釋要好很多:

              ###########
              # Getters #
              ###########
              
            • It is bad style to use @others in organizer nodes. There is no need to do so.

              用 @others 當為組織節點并不好。沒有必要那么做。

            • It is bad style to use @others when order does matter. The reason is that it is very easy to move nodes in a tree by mistake, say by alphabetizing nodes. One wants to make the meaning of a external file immune from such movements.

              當順序是有意義的時候,最好不要使用 @others 。 原因是在一棵樹中很容易誤動節點,比如按字母順序對節點排序。 我們希望這樣的移動對文件沒有任何影響。

            One last word about style. The world won’t end if you happen to use bad style by mistake: you just might cause a bit more work for yourself than was strictly necessary. Feel free to invent your own style of using Leo. Still, it would be wise to “know the rules before you break them.”

            最后再說一點。你由于無意使用了不好的風格,也不會怎樣: 你可能僅僅為自己帶來了一點小麻煩。 在使用 Leo 的過程中你可以創造自己的風格。 但是“在打破規則前了解它們”還是比較明智的。

            Clones & views

            A clone is a node that appears in more than one place in a Leo outline. Clones are marked with a small red arrow in the icon box. All clones of a node are actually the same node, so any change to one clone affects all clones. For example, inserting, moving or deleting any child of a clone will change all other clones on the screen.

            克隆(clone) 是在 Leo 的 outline 中,不止在一個地方出現的節點。 在 icon box 中,以一個紅色的箭頭標記克隆。 一個節點的所有 clone 事實上是 相同的節點 , 所以對任何一個克隆的改變都會影響所有的克隆。 比如,插入,移動或刪除任何克隆的子節點都會導致所有其他克隆的改變。

            Please take a few moments to experiment with clones. Create a node whose headline is A. Clone node A using the Clone Node command in Leo’s Outline menu. Type some text into the body of either clone of A. The same text appears in the bodies of all other clones of A. Now insert a node, say B, as a child of any of the A nodes. All the A nodes now have a B child. See what happens if you clone B. See what happens if you insert, delete or move nodes that are children of A. Verify that when you delete the penultimate clone, the last clone becomes a regular node again.

            請最好花一點時間試試克隆。 創建一個節點,稱其 headline 是 A 。 然后再使用 Leo outline 菜單中的克隆命令對節點 A 進行克隆。 然后再往 A 的任何克隆的 body 中輸入一些文字。 這樣其他克隆中也就會出現相應的文字。 現在,插入一個節點,稱為 B ,作為 A 的子節點。 這樣,所有 A 節點就會有 B 這樣的子節點。 現在,再看看如果克隆了 B 有什么后果。 看看如果你插入,刪除或移動 A 的子節點會發生什么。 核實下當你刪除倒數第二個克隆后,最后一個克隆是不是又變回一個正常的節點了。

            Clones are much more than a cute feature. Clones allow multiple views of data to exist within a single outline. With Leo, there is no such thing as a single, “correct” view of data. You can have as many views of data as you like.

            克隆不止是一個非常好的特性。 克隆允許對數據進行多種視圖。 在 Leo 中,沒有所謂 “正確的”視圖方式。 你可以任由你的喜歡對數據進行視圖。

            To create a new view of the data in your outline, just do the following:

            要創建一個新的視圖方式,只要按下面做就可以了:

            1. Create an ordinary node, that will represent the view. We call these nodes view nodes merely to indicate they represent a view.

              創建一個 正常的 節點,用于代表視圖(view)。 我們稱這些節點為 view node 僅僅是代表一個視圖。

            2. Clone all the nodes from the outline that you want the view to contain. Move these clones so they become children of the view node.

              克隆所有你所需要的節點。然后把它們移到 view node 中。

            3. (Optional) You can add regular nodes as children of the view node too.

              (可選的)你可以增加一個正常的節點作為 view node 的子節點。

            For example, when I fix a bug in Leo, I create an ordinary node to represent the bug. This bug node is my view of all the data in Leo’s source code that relates to the bug. As I discover code related to the bug, I clone their nodes and move them under the bug node. I’ll also add ordinary nodes as children of the bug node. These nodes contain the original bug report, descriptions of how I fixed the bug, test data, or any other notes I might want to keep.

            比如,當我修復了 Leo 中的一個bug時,我會創建一個正常的節點用于表示bug。 這個 bug node 就是用于 bug 相關的視圖。 如果我發現與此 bug 相關的代碼,我會把這段代碼進行克隆,然后移到 bug 節點下。 我也會增加普通的節點作為 bug node 的子節點。 這些節點包含了原始的 bug 報告,我如何修復了這個bug, 測試的數據,或者其他我保留的節點。

            Once I have created the bug node, I concentrate only on that node and its children. I can examine the bug node and its children without having to jump around the outline. Everything I need is in one place. When I get around to actually fixing the bug I can do so by changing the clones. Again, I do not have to jump around the outline. It doesn’t matter how big or complex the entire outline is: I am only dealing with the bug node and its children. This extremely narrow focus makes it much easier to fix bugs.

            一旦我創建了一個 bug 節點,我主需要關注那個節點和它的子節點。 我可以檢驗那個 bug 節點及子節點而無須在 outline 跳轉。 所有我需要做的,就是在一個地方。當我有時間修復了 bug , 我只需要修改 clone 。再次的,我也無須跳轉。 整個 outline 有多大或多復雜都無所謂: 我僅僅需要處理 bug 節點及其子節點即可。 把問題集中在一點就使得修復 bug 變得比較簡單。

            By the way, I never have to remember to save external files. When I change any clone, Leo marks all instances of that clone throughout the entire outline as dirty (changed). When I save the Leo outline, Leo automatically writes all the external files that contain dirty nodes.

            順便說下,我從來不需要記得保存 external 文件。 當我改變了任何一個克隆,Leo 就會標記所有克隆的實例, 整個 outline 被認為是 dirty (改變了)。 當我保存 Leo 的 outline,Leo 自動的會寫入包含 dirty 節點的 external 文件。

            Views have an unlimited number of uses. Use them whenever you want to focus your attention on some smaller set of nodes. For example, I often create view nodes when studying other people’s code. The view node helps me concentrate on just the part of the code that interests me at the moment.

            視圖的使用沒有限制。在你想集中于一些更小的節點集合時就使用它們。 比如,我在研究別人的代碼時,我就會創建視圖節點。 這些視圖節點幫助我集中于某一段我感興趣的代碼。

            More about directives

            Leo’s directives control such things as syntax coloring, line wrapping within the body pane and the width of tabs. Leo directives may appear in headlines or body text. Leo directives start with ‘@’, followed by the name of the directive.

            Leo 的 指令(directive) 控制著一些這樣的事情,如語法加亮, 在 body 面板中行的包裝和 tab 的寬度。Leo的指令可以出現于 headline 或 body 文字中。 Leo的指令以 '@' 開始,而后跟著指令的名字。

            Note: Leo handles Python decorators properly, providing they don’t conflict with Leo’s directives.

            注意 :Leo可以正確的處理 Python 的裝飾器(decorator), 而不會使得與 Leo 的指令相沖突。

            Here are some of Leo’s directives:

            這里是一些 Leo 的指令:

            @language python
            @tabwidth -4
            @wrap
            @nowrap
            @color
            @nocolor
            @killcolor

            Most directives must start with the ‘@’ in the leftmost column, but whitespace may appear before the '@others‘ and '@all‘ directives. As we have seen, such whitespace is significant.

            大多數的指令必需在最左邊的列上以 '@' 開頭, 但是在 '@others''@all' 前可以出現空白。 正如我們所見,這些空白是有意義的。

            Directives apply until overridden in a subtree. All of these directives apply to the node they are contained in, and also to the entire tree of descendant nodes, unless over-ridden by a similar directive in a descendant node. For example, the directive:

            指令在子樹中都會生效直至遇到覆寫。 所有的這些指令在包含它們的節點中都會生效,以及相應的子節點, 除非是在子節點有相同的指令對此進行覆寫。 比如,這個指令:

            @language python

            tells Leo to syntax color the node and all descendant nodes as Python code. However, some descendant node might contain:

            告訴 Leo 以 Python 的語法加亮這個節點及所有派生節點。 但是有些派生的節點可以包含:

            @language rest

            which tells Leo to color that node and all of its descendants as reStructureText. This principle applies to almost all of Leo’s directives: the directive is in effect throughout a tree, unless overridden in some subtree.

            這個就告訴 Leo 以 reStructureText 對這個節點及派生節點進行高亮。 這個原則對幾乎所有的 Leo 指令都適用: 指令在整棵樹中都有效果,除非在一些子樹中被覆寫。

            @color, @nocolor and @killcolor

            These directives control how Leo colors body text. You can mix @nocolor and @color directives in a single node. This directives affect descendant nodes unless a node contains both @color and @color. Such ambiguous nodes do not affect the coloring of descendant nodes.

            這些指令控制這 Leo 如何對 body 中的文字進行加亮。 可以在一個節點中混合使用 @nocolor 和 @color 指令。 這些指令會影響派生的節點除非一個節點中同時包含 @nocolor 和 @color 指令。這樣不確定的節點的子節點就不會受到影響。

            @first

            This directive forces a lines to appear before the first sentinel of a external file. Here is a common way to start a Python file:

            這個指令強行讓一行按順序出現于一個 external 文件中。 此處在 Python 文件中是最常見的:

            @first #! /usr/bin/env python @first # -- coding: utf-8 --

            @language

            Sets the language in effect for a tree. This affects how Leo colors body text. It also sets the comment delimiters used in external files. Leo supports dozens of languages. See Leo’s reference for a complete list. Here are a few:

            設置相應的語言。這就影響 Leo 對 body 文字的加亮方式。 這也設置了在 external 文件中注釋所用的分界符。 Leo 支持挺多語言的。參考 Leo’s reference 。 此處是一些:

            @language python
            @language c
            @language rest # restructured text
            @language plain # plain text: no syntax coloring.

            @pagewidth <n>

            Sets the page width used to format break doc:

            設置格式化文檔時所用的頁寬:

            @pagewidth 100

            @path <path>

            This directive is a convenience. Rather than specifying long paths in @file nodes, you can specify a path in an ancestor @path node. For example, suppose three nodes have the following headlines:

            這個指令很方便。不需要在 @file 中指明很長的路徑, 你可以在一個父節點中指定 @path 節點。 比如,假設有下面三個節點:

            @path a
                @path b
                    @file c/d.py

            Because of the ancestor @path nodes, the @file node creates the file a/b/c/d.py

            因為父節點的 @path ,@file 節點創建的文件會是 a/b/c/d.py

            Within @path and @<file> paths, {{exp}} gets evaluated with the following symbols known: c, g, p, os and sys. For example:

            在 @path 和 @<file> 的路徑中, {{exp}} 會執行下面已知的符號: c,g,p,os和sys。比如:

            @file {{os.path.abspath(os.curdir)}}/abc.py

            refers to the file abc.py in (absolute path of) the current directory.

            就會指向當當前目錄下的 abc.py 文件。

            @tabwidth

            Sets the width of tabs. Negative tab widths cause Leo to convert tabs to spaces and are highly recommended for Python programming.

            設置 tab 的寬度。負的寬度就表示將 tab 轉換為空格,并且這是 Python 編程建議的。

            @wrap and @nowrap.

            These enable or disable line wrapping the Leo’s body pane.

            這個開啟或關閉行包裝。

            Scripting, extending and customizing Leo

            Leo is fully scriptable using the Python language. Leo can execute any body text as a Python script. To run the entire body text as a script, simply choose the node and execute the Execute Script command (Ctrl+B). If text is selected, the Execute Script command will run just the selected text as the script.

            Leo 可以使用 Python 進行腳本編程。 Leo 可以將任意的 body 文字作為 Python 腳本執行。 為了將一整段作為腳本執行,只要選中相應的節點, 然后執行執行腳本的命令(Ctrl+B)。 如果有文字被選中,那么就會只執行選中的部分。

            The Execute Script command preprocesses the script before executing it, in exactly the same way that Leo writes external files. Leo expands section references and processes @others directives before executing the script. This allows you to use all of Leo’s outlining capabilities to organize your scripts.

            執行腳本命令在執行它之前將預處理這個腳本, 這和 Leo 寫入 external 文件是一樣的。 在執行這個腳本前, Leo 將會擴展 section reference 和處理 @others 指令。 這個就允許你使用 Leo 的 outline 來組織你的腳本。

            Your Python scripts can easily access data in an outline. Leo’s execute-script (Ctrl-B) command predefines three variables, c, g and p, that scripts can use to easily access any part of any Leo outline, and Leo’s own source code. For example, the following script will print all the headlines in an outline:

            你的 Python 腳本可以很容易訪問在 outline 中的數據。 Leo 的執行腳本(Ctrl-B)命令預定義了三個變量,c,g和p, 這樣腳本可以訪問 Leo 的 outline 的任意部分, 以及 Leo 自身的代碼。 舉個例子,下面的腳本將會打印所有的 headline:

            for p in c.all_positions():
                print ' '*p.level(),p.h
            

            The example above is only the beginning of what scripts can do. See Scripting Leo with Python for a complete discussion of scripting Leo.

            上面的例子僅僅是腳本可以做什么的開端。 參考 Scripting Leo with Python 有更詳細的討論。

            Plugins are Python modules that change how Leo works. Leo’s user have contributed dozens of plugins that have extended Leo’s capabilities in many new directions. The file leoPlugins.leo contains all plugins that are included in Leo distributions.

            Plugin 是 Python 的模塊用于改變 Leo 運行的方式。 Leo 的用戶貢獻了大量的插件用于擴展 Leo 在各方面的能力。 文件 leoPlugin.leo 包含了 Leo 發行版中所有的插件。

            Plugins and other parts of Leo can get options from @settings trees. @settings trees allow plugins to get options without any further support from Leo’s core code. For a full discussion of @settings trees, see Customizing Leo.

            插件和其他部分可以從 @settings 樹中獲取選項。 @settings 樹允許插件獲取選項而無須 Leo 核心代碼的支持。 關于此的更多討論,參考 Customizing Leo

            Summary

            Using Leo quickly becomes second nature:

            使用 Leo 迅速變為第二種特性:

            • You can use Leo like any ordinary outliner, as a filing cabinet, but Leo’s clones makes this filing cabinet much more flexible and useful than usual.

              你可以像任何普通的 outline 軟件一樣使用 Leo, 像一個文件柜,但是 Leo 的克隆使得這個文件柜更靈活實用。

            • You create external files using @file trees. Within @file trees, you use section references and the @others directive to tell Leo how to write nodes to the external file. Directives such as @tabwidth and @language provide other information to Leo. Leo’s @file trees allow you to organize your scripts and programs with Leo’s outline structure.

              你可以使用 @file 創建 external 文件。 有了 @file 樹,你可以用 section reference 以及 @others 指令告訴 Leo 如何把節點寫入 Leo。 Leo 的 @file 使得你可以用 Leo 的 outline 組織你的腳本和程序。

            • You can execute Python scripts from any node in a Leo outline. Leo scripts have full, easy, access to all the information in the outline. Using scripts and plugins, you can easily add new features to Leo.

              在一個 Leo 的 outline 中,你可以從任何一個節點中運行 Python 腳本。 Leo 腳本可以訪問 outline 中的所有信息。 使用腳本和插件,你可以輕松增加新的特性。

            Further study

            LeoPyRef.leo (in the core subdirectory of the leo folder) contains almost all of Leo’s source code. It provides hundreds of examples of everything discussed here. This file will repay close study. For full details on all aspects of Leo see LeoDocs.leo.

            LeoPyRef.leo(在leo目錄的core目錄下)包含了幾乎所有的 Leo 源代碼。 它提供了這里討論過的很多的例子。 這個文件值得深入學習。關于 Leo 各方面的詳情參考 LeoDocs.leo。

            posted on 2012-02-03 12:50 mirguest 閱讀(1559) 評論(0)  編輯 收藏 引用 所屬分類: Python

            AV狠狠色丁香婷婷综合久久| 狠狠精品久久久无码中文字幕| 99久久久精品免费观看国产| 久久天天躁狠狠躁夜夜躁2O2O| 99久久99久久久精品齐齐| 久久精品无码av| 久久久久99精品成人片试看| 精品乱码久久久久久夜夜嗨| 久久久SS麻豆欧美国产日韩| 2020最新久久久视精品爱| 久久久久亚洲av成人网人人软件 | 精品熟女少妇av免费久久| 久久国产高清字幕中文| 久久久黄色大片| 久久国产热这里只有精品| 蜜臀av性久久久久蜜臀aⅴ| 久久午夜福利电影| 久久精品国产精品亚洲人人| 久久99精品国产麻豆| 无码国内精品久久人妻蜜桃 | 丁香五月综合久久激情| 久久影院综合精品| 久久99这里只有精品国产| 九九久久精品无码专区| 草草久久久无码国产专区| 国产成年无码久久久久毛片| 日韩人妻无码精品久久免费一| 一本久道久久综合狠狠躁AV| 久久91这里精品国产2020| 国产激情久久久久影院老熟女免费 | 99久久99久久精品国产片| 国产精品美女久久久m| 久久国产色AV免费看| 久久亚洲私人国产精品vA| 亚洲AV无码1区2区久久| 亚洲中文久久精品无码| 久久久久亚洲av无码专区喷水 | 久久狠狠一本精品综合网| 久久久久99精品成人片| 久久免费99精品国产自在现线| 日本久久中文字幕|