Index: jrst2/src/test/org/codelutin/jrst/test.rst diff -u jrst2/src/test/org/codelutin/jrst/test.rst:1.2 jrst2/src/test/org/codelutin/jrst/test.rst:1.3 --- jrst2/src/test/org/codelutin/jrst/test.rst:1.2 Thu May 3 16:37:08 2007 +++ jrst2/src/test/org/codelutin/jrst/test.rst Fri May 4 16:23:28 2007 @@ -1,181 +1,112 @@ -=============== -Docinfo Example -=============== +==================== + |reStructuredText| +==================== +------------------------------------------------- + Markup Syntax and Parser Component of Docutils_ +------------------------------------------------- -:Author: J. Random Hacker -:Contact: jrh@example.com -:Date: 2002-08-18 -:Status: Work In Progress -:Version: 1 -:Filename: $RCSfile: test.rst,v $ -:Copyright: This document has been placed in the public domain. -:Address: 123 Example Ave. Example, EX -:Authors: J. Random Hacker; Jane Doe -:Organization: Humankind -:Revision: b +:Date: $Date: 2007/05/04 16:23:28 $ -Admonition ----------- +.. contents:: -.. admonition:: And, by the way... +reStructuredText is an easy-to-read, what-you-see-is-what-you-get +plaintext markup syntax and parser system. It is useful for in-line +program documentation (such as Python docstrings), for quickly +creating simple web pages, and for standalone documents. +reStructuredText is designed for extensibility for specific +application domains. The reStructuredText parser is a component of +Docutils_. reStructuredText is a revision and reinterpretation of the +StructuredText_ and Setext_ lightweight markup systems. - You can make up your own admonition too. +The primary goal of reStructuredText is to define and implement a +markup syntax for use in Python docstrings and other documentation +domains, that is readable and simple, yet powerful enough for +non-trivial use. The intended purpose of the markup is the conversion +of reStructuredText documents into useful structured data formats. -.. Attention:: All your base are belong to us. +See statemachine.py_ for an example of a Python module fully +documented using reStructuredText. -.. DANGER:: Mad scientist at work! -.. Caution:: Don't take any wooden nickels. +User Documentation +================== -.. Error:: Does not compute. +- `A ReStructuredText Primer`__ (HTML file, or `text source`__). +- `Quick reStructuredText`__ (user reference) +- `reStructuredText Cheat Sheet`__ (text only; 1 page for syntax, 1 + page directive & role reference) -.. Note:: Admonitions can be handy to break up a - long boring technical document. - -.. Tip:: 15% if the service is good. +Users who have questions or need assistance with Docutils or +reStructuredText should post a message to the Docutils-users_ mailing +list. -.. WARNING:: Reader discretion is strongly advised. +__ docs/user/rst/quickstart.html +__ docs/user/rst/quickstart.txt +__ docs/user/rst/quickref.html +__ docs/user/rst/cheatsheet.txt +.. _Docutils-users: docs/user/mailing-lists.html#docutils-users -.. topic:: Title - Body. +Reference Documentation +======================= -As a great paleontologist once said, +- `An Introduction to reStructuredText`__ (includes the Goals__ and + History__ of reStructuredText) +- `reStructuredText Markup Specification`__ +- `reStructuredText Directives`__ +- `reStructuredText Interpreted Text Roles`__ - This theory, that is mine, is mine. +__ docs/ref/rst/introduction.html +__ docs/ref/rst/introduction.html#goals +__ docs/ref/rst/introduction.html#history +__ docs/ref/rst/restructuredtext.html +__ docs/ref/rst/directives.html +__ docs/ref/rst/roles.html - -- Anne Elk (Miss) - -- Item 1, paragraph 1. - Item 1, paragraph 2. +Developer Documentation +======================= -- Item 2. +- `A Record of reStructuredText Syntax Alternatives`__ +- `Problems With StructuredText`__ -name : string - Customer name. -i : int - Temporary index variable. - -A paragraph. +__ docs/dev/rst/alternatives.html +__ docs/dev/rst/problems.html -Term - Definition. -Term : classifier - The ' : ' indicates a classifier in - definition list item terms only. - -Tyrannosaurus Rex : carnivore - Big and scary; the "Tyrant King". - -Brontosaurus : herbivore - All brontosauruses are thin at one end, - much much thicker in the middle - and then thin again at the far end. - - -- Anne Elk (Miss) - -This is an ordinary paragraph. - ->>> print 'this is a Doctest block' -this is a Doctest block - -A Title -======= - -A paragraph. - -1. Item 1. - - (A) Item A. - (B) Item B. - (C) Item C. - -2. Item 2. - -:Author: Me -:Version: 1 -:Date: 2001-08-11 -:Parameter i: integer - -.. header:: This space for rent. - -.. Hint:: It's bigger than a bread box. - -.. Important:: - - * Wash behind your ears. - * Clean up your room. - * Back up your data. - * Call your mother. - -Take it away, Eric the Orchestra Leader! - -| A one, two, a one two three four -| -| Half a bee, philosophically, -| must, *ipso facto*, half not be. -| But half the bee has got to be, -| *vis a vis* its entity. D'you see? -| -| But can a bee be said to be -| or not to be an entire bee, -| when half the bee is not a bee, -| due to some ancient injury? -| -| Singing... - -1. Outer list, item 1. - - * Inner list, item 1. - * Inner list, item 2. - -2. Outer list, item 2. - -Here is a literal block:: - - if literal_block: - text = 'is left as-is' - spaces_and_linebreaks = 'are preserved' - markup_processing = None - --a command-line option "a" --1 file, --one=file, --two file - Multiple options with arguments. - -Title 1 -======= -Paragraph 1. +How-To's +-------- -Title 2 -------- -Paragraph 2. +- `Creating reStructuredText Directives`__ +- `Creating reStructuredText Interpreted Text Roles`__ -Title 3 -======= -Paragraph 3. +__ docs/howto/rst-directives.html +__ docs/howto/rst-roles.html -Title 4 -------- -Paragraph 4. -.. sidebar:: Title - :subtitle: If Desired +Try it Online +============= - Body. +If you want to try reStructuredText out without downloading Docutils, +you can use the `reStructuredText online renderer`__. Thanks to Jiri +Barton for `setting it up`__! -======= - Title -======= ----------- - Subtitle ----------- +__ http://www.hosting4u.cz/jbar/rest/rest.html +__ http://www.hosting4u.cz/jbar/rest/about.html -A paragraph. +.. _Docutils: index.html +.. _StructuredText: + http://dev.zope.org/Members/jim/StructuredTextWiki/FrontPage/ +.. _Setext: mirror/setext.html +.. _statemachine.py: docutils/statemachine.py -Paragraph 1. +.. |reStructuredText| image:: rst.png --------- -Paragraph 2. +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + End: Index: jrst2/src/test/org/codelutin/jrst/footnoteTest.rst diff -u jrst2/src/test/org/codelutin/jrst/footnoteTest.rst:1.1 jrst2/src/test/org/codelutin/jrst/footnoteTest.rst:1.2 --- jrst2/src/test/org/codelutin/jrst/footnoteTest.rst:1.1 Thu May 3 16:37:08 2007 +++ jrst2/src/test/org/codelutin/jrst/footnoteTest.rst Fri May 4 16:23:28 2007 @@ -1,8 +1,13 @@ -[#]_ is a reference to footnote 1, and [#]_ is a reference to -footnote 2. +Autonumbered footnotes are +possible, like using [#]_ and [#]_. -.. [#] This is footnote 1. -.. [#] This is footnote 2. -.. [#] This is footnote 3. +.. [#] This is the first one. +.. [#] This is the second one. -[#]_ is a reference to footnote 3. +They may be assigned 'autonumber +labels' - for instance, +[#fourth]_ and [#third]_. + +.. [#third] a.k.a. third_ + +.. [#fourth] a.k.a. fourth_ Index: jrst2/src/test/org/codelutin/jrst/text.rst diff -u jrst2/src/test/org/codelutin/jrst/text.rst:1.12 jrst2/src/test/org/codelutin/jrst/text.rst:1.13 --- jrst2/src/test/org/codelutin/jrst/text.rst:1.12 Thu May 3 16:37:08 2007 +++ jrst2/src/test/org/codelutin/jrst/text.rst Fri May 4 16:23:28 2007 @@ -268,11 +268,13 @@ at least 2 spaces between option & description 'frungible doodads'_ [#aaaa]_ + +.. [#aaaa] aaaaaaa .. _frungible doodads: http://www.example.org/ .. [#] "Bogus Complexity Addition" .. [9] "Bogus Complexity Addition" - + .. [#pep9876] PEP 9876, Let's Hope We Never Get Here Index: jrst2/src/test/org/codelutin/jrst/Compare.java diff -u /dev/null jrst2/src/test/org/codelutin/jrst/Compare.java:1.1 --- /dev/null Fri May 4 16:23:33 2007 +++ jrst2/src/test/org/codelutin/jrst/Compare.java Fri May 4 16:23:28 2007 @@ -0,0 +1,173 @@ +package org.codelutin.jrst; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.URL; +import java.util.Iterator; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.JFrame; + +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextArea; + + +import org.codelutin.jrst.JRSTReader; +import org.dom4j.Document; +import org.dom4j.io.SAXReader; + +import org.dom4j.Element; + + + + +public class Compare { + private static final String PATH="/home/letellier/PROJET/jrst2/"; + static public void main(String [] args) throws Exception { + File source = null; + if (args.length>0){ + source = new File(args[0]); + if (source != null) + parser(source); + } + else + System.err.println("Argument source manquant"); + } + + private static void parser(File source) throws Exception { + URL url = source.toURL(); + Reader in = new InputStreamReader(url.openStream()); + JRSTReader jrst = new JRSTReader(); + Document docRst = jrst.read(in); + String cmd = "rst2xml "+PATH+source.getPath()+" "+PATH+"src/test/org/codelutin/jrst/comparePython.xml"; + System.out.println(cmd); + Runtime.getRuntime().exec("rm "+PATH+"src/test/org/codelutin/jrst/comparePython.xml"); + final Process p =Runtime.getRuntime().exec(cmd); + //Runtime.getRuntime().exec(new String[] { "rst2xml", PATH+source.getPath(), PATH+"src/test/org/codelutin/jrst/comparePython.xml" }); + + Thread t = new Thread() { + public void run() { + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(p.getErrorStream())); + String line = ""; + try { + while((line = reader.readLine()) != null) { + System.err.println(line); + } + } finally { + reader.close(); + } + } catch(IOException ioe) { + ioe.printStackTrace(); + } + } + }; + t.start(); + while(t.isAlive()); + t.stop(); + p.destroy(); + + File xml = new File("src/test/org/codelutin/jrst/comparePython.xml"); + + SAXReader sr= new SAXReader(); + Document docPython = sr.read(xml); + + + + + compare(docRst, docPython); + + } + + private static void compare(Document docRst, Document docPython) throws IOException { + + + JTextArea jrst = new JTextArea(); + JTextArea python = new JTextArea(); + jrst.setText(convert(docRst.asXML())); + python.setText(convert(docPython.asXML())); + + + JScrollPane droit = new JScrollPane(jrst); + JScrollPane gauche = new JScrollPane(python); + JFrame comparateur = new JFrame(); + JSplitPane separateur = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true, gauche,droit); + separateur.setResizeWeight(0.5); + separateur.setOneTouchExpandable(true); + separateur.setContinuousLayout(true); + comparateur.add(separateur); + + comparateur.setSize(1280, 900); + comparateur.setVisible(true); + comparateur.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + } + private static String convert(String xml) throws IOException { + + + + + String txt=""; + txt+="\n"+xml.replaceAll("><", ">\n<"); + + StringReader sr = new StringReader(txt); + BufferedReader bf= new BufferedReader(sr); + Pattern ligneFinit = Pattern.compile("(^<.+())|(^<\\?)|(^<\\!)"); + Pattern ligneOuvrante = Pattern.compile("^<.+>$"); + Pattern ligneFermante = Pattern.compile("^$"); + String line = bf.readLine(); + String txtFin=""; + int level = 0; + String sLevel = ""; + boolean ouvrante=false; + int cnt=0; + while (line!=null){ + cnt++; + sLevel=""; + for (int i = 0;i + + + + + <image alt="reStructuredText" uri="rst.png"/> + + Markup Syntax and Parser Component of Docutils + + + 2006-09-22 16:36:33 +0200 (Fri, 22 Sep 2006) + + + Contents + + + + User Documentation + + + + + Reference Documentation + + + + + Developer Documentation + + + + + How-To's + + + + + + + Try it Online + + + + + reStructuredText is an easy-to-read, what-you-see-is-what-you-get +plaintext markup syntax and parser system. It is useful for in-line +program documentation (such as Python docstrings), for quickly +creating simple web pages, and for standalone documents. +reStructuredText is designed for extensibility for specific +application domains. The reStructuredText parser is a component of +Docutils. reStructuredText is a revision and reinterpretation of the +StructuredText and Setext lightweight markup systems. + The primary goal of reStructuredText is to define and implement a +markup syntax for use in Python docstrings and other documentation +domains, that is readable and simple, yet powerful enough for +non-trivial use. The intended purpose of the markup is the conversion +of reStructuredText documents into useful structured data formats. +See statemachine.py for an example of a Python module fully +documented using reStructuredText. +
+ User Documentation + + + +A ReStructuredText Primer (HTML file, or text source). + + + +Quick reStructuredText (user reference) + + + +reStructuredText Cheat Sheet (text only; 1 page for syntax, 1 +page directive & role reference) + + + Users who have questions or need assistance with Docutils or +reStructuredText should post a message to the Docutils-users mailing +list. + + + + + +
+
+ Reference Documentation + + + +An Introduction to reStructuredText (includes the Goals and +History of reStructuredText) + + + +reStructuredText Markup Specification + + + + +reStructuredText Directives + + + + +reStructuredText Interpreted Text Roles + + + + + + + + + +
+
+ Developer Documentation + + + +A Record of reStructuredText Syntax Alternatives + + + + +Problems With StructuredText + + + + + +
+ How-To's + + + +Creating reStructuredText Directives + + + + +Creating reStructuredText Interpreted Text Roles + + + + + +
+
+
+ Try it Online + If you want to try reStructuredText out without downloading Docutils, +you can use the reStructuredText online renderer. Thanks to Jiri +Barton for setting it up! + + + + + + + + reStructuredText + + Local Variables: +mode: indented-text +indent-tabs-mode: nil +sentence-end-double-space: t +fill-column: 70 +End: +
+