r656 - in branches/jrst-docutils-jython: docutils/src/main/resources/docutils jrst/src/main/java/org/nuiton/jrst jrst/src/test/java/org/nuiton/jrst jrst/src/test/java/org/nuiton/jrst/bugs
Author: jpages Date: 2012-05-04 17:41:03 +0200 (Fri, 04 May 2012) New Revision: 656 Url: http://nuiton.org/repositories/revision/jrst/656 Log: Docutils scripts can be used several times without causing errors now. JRST can generate now Docbook, xdoc, etc.. and new formats with Docutils (Latex, ODT, etc..). Modified: branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTConfigOption.java branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTGeneratorTest.java branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java Modified: branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py =================================================================== --- branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py 2012-05-04 15:41:03 UTC (rev 656) @@ -5,58 +5,64 @@ from java.io import File, InputStream from java.net import URL, JarURLConnection -def init_docutils(namefile, filepath): - # Save the path of __run__.py - pathname = os.path.abspath(os.path.dirname(namefile)) #sys.argv[0] - - # Add the lib path to sys.path - lib_path = os.path.dirname(filepath) #sys.argv[1] - sys.path.append(lib_path) - +def init_docutils(docutilsPath): # Check if the new open function doesn't exist if "openlegacy" not in __builtin__.__dict__: # Define the function jaropen which will be able to read into the jar. - # TODO : Mettre des exemples et expliquer le code suivant pour ceux qui prendront le projet ensuite - # TODO : Modifier pour que cela fonctionne avec pour la génération de site - def jaropen(jarpath, mode, bufsize=-1): - print "jarpath " + jarpath - if "__pyclasspath__" in jarpath: - filepath = "jar:file:" + lib_path + "!" - jarpath = string.replace(jarpath, "__pyclasspath__", filepath) - url = URL(jarpath) + # Examples : + # If the value of the resourcePath is + # '/home/user/workspace/jrst-docutils-jython/jrst/src/test/resources/text.rst', + # the classic function "open" can be used, but if the value is + # '__pyclasspath__/docutils/writers/html4css1/html4css1.css', + # python doesn't be able to find the resource, so it must have the + # absolute path to the jar to read it with jaropen after. + # + # TODO (?) : Modifier pour que cela fonctionne avec pour la génération de site + def jaropen(resourcePath, mode, bufsize=-1): + print "resourcePath " + resourcePath + if "__pyclasspath__" in resourcePath: + # Replace the relative resource filepath by the absolute path + docutilsAbsolutePath = "jar:file:" + os.path.dirname(docutilsPath) + "!" + resourcePath = string.replace(resourcePath, "__pyclasspath__", docutilsAbsolutePath) + # Get the url and open a stream to access to the resource + # /!\ Warning : we use a deprecated function, it will could be a problem later + url = URL(resourcePath) inStream = url.openStream() - print "new jarpath : " + jarpath + print "new resourcePath : " + resourcePath f = __builtin__.openlegacy(inStream, bufsize) else: - f = __builtin__.openlegacy(jarpath, mode, bufsize) + f = __builtin__.openlegacy(resourcePath, mode, bufsize) return f - # Replace in the dictionnary the old open function by the new one + # Replace in the dictionnary the old open function by the new one (openlegacy) __builtin__.__dict__["openlegacy"] = __builtin__.__dict__["open"] __builtin__.__dict__["open"] = jaropen -def exec_docutils (filepath, typeOutput, filein, fileout): +def exec_docutils (docutilsPath, typeOutput, filein, fileout): + + # Initalization before using Docutils + init_docutils(docutilsPath) + # Add the lib path to sys.path - lib_path = os.path.dirname(filepath) + lib_path = os.path.dirname(docutilsPath) sys.path.append(lib_path) # Add the scripts path to sys.path scriptpath = lib_path + '/build/scripts-2.7' sys.path.append(scriptpath) - # Call publish_file with the good arguments typeOutput = typeOutput.lower() - - print "filein : " + filein - print "fileout : " + fileout - print "writer_name : " + typeOutput - - # If Docutils can manage this output format, we call it - from docutils.core import publish_file - + + # Check if the output type is supported by Docutils listType = ["xml", "html", "odt", "latex", "man", "s5", "xetex"] if typeOutput in listType: + # With odt, man and s5 formats, the 'publish_file' function causes + # the error "IOError: StreamIO.seek() not supported" + # and the 'publish_cmdline_to_binary' function causes + # "__run__: error: Maximum 2 arguments allowed.". + # We must call the docutils script but execfile cannot be used with + # arguments, we have to use 'subprocess.call()' import subprocess if typeOutput == "odt": subprocess.call(['rst2odt.py', filein, fileout]) @@ -65,13 +71,9 @@ elif typeOutput == "s5": subprocess.call(['rst2s5.py', filein, fileout]) else: + # We can use 'publish_file' with the other format + from docutils.core import publish_file print publish_file( source_path=filein, destination_path=fileout, writer_name=typeOutput ) else: print "Wrong output format" - - -#if __name__ == "__main__": -# exec_docutils(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) -#elif __name__ == "__runpy__": -# exec_docutils(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-04 15:41:03 UTC (rev 656) @@ -8,16 +8,16 @@ * Copyright (C) 2004 - 2011 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% @@ -57,10 +57,6 @@ import org.nuiton.util.FileUtil; import org.nuiton.util.Resource; import org.nuiton.util.StringUtil; -import org.python.core.*; -import org.python.core.adapter.ExtensiblePyObjectAdapter; -import org.python.modules.zipimport.zipimporter; -import org.python.util.JarRunner; import org.python.util.PythonInterpreter; /** @@ -83,10 +79,26 @@ NEVER, IFNEWER, ALLTIME } - public enum Format { + // Formats created with Docutils and Jython + public enum Docutils_Formats { XML, HTML, PDF, ODT, LATEX, S5, XETEX, MAN, RST } + // Ancient formats created by JRST + public static final String[] Other_Formats = { + "xhtml", + "htmlInnerBody", + "xdoc", + "docbook", + "html", + "javahelp", + "htmlhelp", + "rst", + "odt", + "fo", + "pdf" + }; + /** to use log facility, just put in your code: log.info("..."); */ protected static Log log = LogFactory.getLog(JRST.class); @@ -138,9 +150,6 @@ /** RST output format type */ public static final String TYPE_RST = "rst"; - /** ODT output format type */ - public static final String TYPE_ODT = "odt"; - /** FO output format type */ public static final String TYPE_FO = "fo"; @@ -168,7 +177,6 @@ stylesheets.put(TYPE_JAVAHELP, rst2docbook + "," + docbook2javahelp); stylesheets.put(TYPE_HTMLHELP, rst2docbook + "," + docbook2htmlhelp); stylesheets.put(TYPE_RST, ""); - //stylesheets.put(TYPE_ODT, rst2docbook + "," + docbook2odf); stylesheets.put(TYPE_FO, rst2docbook + "," + docbook2fo); stylesheets.put(TYPE_PDF, rst2docbook + "," + docbook2fo); @@ -180,7 +188,6 @@ mimeType.put(TYPE_JAVAHELP, "text/plain"); mimeType.put(TYPE_HTMLHELP, "text/html"); mimeType.put(TYPE_RST, "text/plain"); - mimeType.put(TYPE_ODT, "application/vnd.oasis.opendocument.text"); mimeType.put(TYPE_FO, "text/xml"); mimeType.put(TYPE_PDF, "application/pdf"); @@ -270,10 +277,10 @@ public static void generate(String outputType, File fileIn, File fileOut, Overwrite overwrite) throws Exception { - generate(outputType, fileIn, UTF_8, fileOut, UTF_8, overwrite); + generate(outputType, fileIn, fileOut, UTF_8, overwrite); } - public static void generate(String outputType, File fileIn, String inputEncoding, + public static void generate(String outputType, File fileIn, File fileOut, String outputEncoding, Overwrite overwrite) throws Exception { if (fileOut != null @@ -282,56 +289,66 @@ .isNewer(fileIn, fileOut)))) { log.info("Don't generate file " + fileOut + ", because already exists"); - //} else if (outputType.equals("PDF") || outputType.equals("RST")) { } else { - // Out - FileOutputStream outputStream = new FileOutputStream(fileOut); - OutputStreamWriter writer = new OutputStreamWriter(outputStream, outputEncoding); + // Does the output format require Docutils ? + // The default value is yes because the main script of docutils manage wrong format error + boolean new_format = true; + for (int i = 0; i < Other_Formats.length; i++) { + if (Other_Formats[i].equals(outputType)) { + new_format = false; + } + } - // Generate - String result = generateString(outputType, fileIn); + if (new_format) { // If the format needs docutils : + generateDocument(outputType, fileIn, fileOut); - fileOut.getAbsoluteFile().getParentFile().mkdirs(); + } else { // Else, we use xsl transformation + // Out + FileOutputStream outputStream = new FileOutputStream(fileOut); + OutputStreamWriter writer = new OutputStreamWriter(outputStream, outputEncoding); - // generation PDF - if (outputType.equals("pdf")) { - FopFactory fopFactory = FopFactory.newInstance(); + // Generate + String result = generateString(outputType, fileIn); - OutputStream outPDF = new BufferedOutputStream(new FileOutputStream( - fileOut)); + fileOut.getAbsoluteFile().getParentFile().mkdirs(); - FOUserAgent userAgent = fopFactory.newFOUserAgent(); + // generation PDF + if (outputType.equals("pdf")) { + FopFactory fopFactory = FopFactory.newInstance(); - // Step 3: Construct fop with desired output format - Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, - userAgent, outPDF); + OutputStream outPDF = new BufferedOutputStream(new FileOutputStream( + fileOut)); - // Step 4: Setup JAXP using identity transformer - TransformerFactory factory = TransformerFactory - .newInstance(); - Transformer transformer = factory.newTransformer(); // identity - // transformer + FOUserAgent userAgent = fopFactory.newFOUserAgent(); - // Step 5: Setup input and output for XSLT transformation - // Setup input stream - Source src = new StreamSource(new StringReader(result)); + // Step 3: Construct fop with desired output format + Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, + userAgent, outPDF); - // Resulting SAX events (the generated FO) must be piped - // through to FOP - Result res = new SAXResult(fop.getDefaultHandler()); + // Step 4: Setup JAXP using identity transformer + TransformerFactory factory = TransformerFactory + .newInstance(); + Transformer transformer = factory.newTransformer(); // identity + // transformer - // Step 6: Start XSLT transformation and FOP processing - transformer.transform(src, res); + // Step 5: Setup input and output for XSLT transformation + // Setup input stream + Source src = new StreamSource(new StringReader(result)); - outPDF.close(); - } else { - // write generated document - writer.write(result); - writer.close(); - } - /*} else { */ - //generateDocument(outputType, fileIn, fileOut); + // Resulting SAX events (the generated FO) must be piped + // through to FOP + Result res = new SAXResult(fop.getDefaultHandler()); + // Step 6: Start XSLT transformation and FOP processing + transformer.transform(src, res); + + outPDF.close(); + } else { + // write generated document + writer.write(result); + writer.close(); + } + } } } @@ -426,6 +443,17 @@ public static Document generateXML(File in) throws Exception { + // RST to XML transformation via Docutils and a temporary file + File out = File.createTempFile("result", ".xml"); + out = generateDocument(Docutils_Formats.XML.name(), in, out); + + SAXReader saxReader = new SAXReader(); + return saxReader.read(out); + } + + + public static File generateDocument(String outputType, File in, File out) throws Exception { + // Name of the main Python script final String runner = "__run__"; /* Transformation of the __run__ URL into a path that python will use @@ -439,88 +467,22 @@ String docutilsPath = resource.getPath().replaceAll("__run__.py", ""); docutilsPath = docutilsPath.replaceAll("!", ""); docutilsPath = docutilsPath.replaceAll("file:", ""); - - // Creation of a temporary file to save the xml result log.info("docutilsPath = "+docutilsPath); - File out = File.createTempFile("result", ".xml"); - /* - Properties props = PySystemState.getBaseProperties(); - props.setProperty("python.path", docutilsPath); - String[] argv = new String[]{runner, docutilsPath, Format.XML.name(), in.getPath(), out.getPath()}; - log.info("Run Python with args: " + Arrays.toString(argv)); - - - if (INITIALIZED) { - Field initialized = PySystemState.class.getDeclaredField("initialized"); - initialized.setAccessible(true); - initialized.set(null, false); - - Field registry = PySystemState.class.getDeclaredField("registry"); - registry.setAccessible(true); - registry.set(null, null); - - } else { - INITIALIZED = true; - } - - PythonInterpreter.initialize(PySystemState.getBaseProperties(), props, argv); */ - // Import of the main script to use docutils ( __run__ ) PythonInterpreter interp = new PythonInterpreter(); - StringBuilder command = new StringBuilder("import __run__"); - log.info(command.toString()); - interp.exec(command.toString()); + String commandImport = "import __run__"; + interp.exec(commandImport); - // Initialization of the docutils environment (adds jaropen in the built-in functions) - command = new StringBuilder("__run__.init_docutils(\""); - command.append(runner).append("\", \"") // The name of the script - .append(docutilsPath).append("\")"); // The docutils jar path - log.info(command.toString()); - interp.exec(command.toString()); - // Execution of the docutils script to transform rst to xml - command = new StringBuilder("__run__.exec_docutils(\""); - command.append(docutilsPath).append("\", \"") // The docutils jar path - .append(Format.XML.name()).append("\", \"") // The outpout format (here XML) - .append(in.getPath()).append("\", \"") // The input file path - .append(out.getPath()).append("\")"); // The output file path - log.info(command.toString()); - interp.exec(command.toString()); - /* - interp.execfile(in.getClass().getResourceAsStream("/__run__.py")); - interp.getSystemState().cleanup(); - */ + String commandExec = String.format("__run__.exec_docutils('%s', '%s', '%s', '%s')", + docutilsPath, outputType, in.getPath(), out.getPath()); + log.info(commandExec); + interp.exec(commandExec); + + // Cleaning the python interpreter to avoid problems if they are multiple execution of this method interp.cleanup(); - log.info("out content =\n"+FileUtils.readFileToString(out)+"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - SAXReader saxReader = new SAXReader(); - return saxReader.read(out); - } - - - public static File generateDocument(String outputType, File in, File out) throws Exception { - // On récupère le chemin vers le script principal de docutils - URL resource = in.getClass().getResource("/__run__.py"); - String docutilsPath = resource.getPath().replaceAll("__run__.py", ""); - docutilsPath = docutilsPath.replaceAll("!", ""); - docutilsPath = docutilsPath.replaceAll("file:", ""); - - String[] argv = new String[]{"__run__.py", docutilsPath, outputType, in.getPath(), out.getPath()}; - - // Only for debugging - if (log.isDebugEnabled()){ - String message = "Run Python with args: " + Arrays.toString(argv); - log.debug(message); - } - - Properties props = PySystemState.getBaseProperties(); - System.out.println(props.getProperty("python.path")); - props.setProperty("python.path", docutilsPath); - PythonInterpreter.initialize(PySystemState.getBaseProperties(), props, argv); - PythonInterpreter interp = new PythonInterpreter(); - interp.execfile(docutilsPath + "__run__.py"); - return out; } Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTConfigOption.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTConfigOption.java 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTConfigOption.java 2012-05-04 15:41:03 UTC (rev 656) @@ -44,7 +44,7 @@ OUT_FILE("outFile", n_("jrst.option.outfile"), null, String.class, true, false), OUT_TYPE("outType", n_("jrst.option.outtype"), null, String.class, true, false), XSL_FILE("xslFile", n_("jrst.option.xslfile"), null, String.class, true, false), - INTERMEDIATE_FILE("intermediateFile", n_("jrst.option.intermediatefile"), JRST.Format.HTML.name(), + INTERMEDIATE_FILE("intermediateFile", n_("jrst.option.intermediatefile"), JRST.Docutils_Formats.HTML.name(), String.class, true, false); public String key; Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTGeneratorTest.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTGeneratorTest.java 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTGeneratorTest.java 2012-05-04 15:41:03 UTC (rev 656) @@ -70,7 +70,6 @@ * Test ignoré car un des fichier contenu dans le jar de docutils n'est pas trouvé * @throws Exception */ - @Ignore @Test public void testRstToHtml() throws Exception { Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java 2012-05-04 15:41:03 UTC (rev 656) @@ -103,7 +103,7 @@ File out = new File(testWorkDir, "toRst1-out.rst"); - JRST.generate(JRST.Format.RST.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.RST.name(), in, out, JRST.Overwrite.ALLTIME); List<?> readLines = FileUtils.readLines(out); log.info(OUT_LINES); @@ -120,35 +120,27 @@ public void generateXml() throws Exception { File in = getTestFile("text.rst"); - File out = getOutputTestFile("jrst-RstToXml1.xml"); + File out = getOutputTestFile("jrst-RstToXml.xml"); - JRST.generate(JRST.Format.XML.name(), in, out, JRST.Overwrite.ALLTIME); - File out2 = getOutputTestFile("jrst-RstToXml2.xml"); - try { - JRST.generate(JRST.Format.XML.name(), in, out2, JRST.Overwrite.ALLTIME); - } catch (Throwable e) { - e.printStackTrace(); - } + JRST.generate(JRST.Docutils_Formats.XML.name(), in, out, JRST.Overwrite.ALLTIME); } @Test public void generateHtml() throws Exception { File in = getTestFile("text.rst"); - File out = getOutputTestFile("jrst-RstToHtml2.html"); - JRST.generate(JRST.Format.HTML.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); } @Test public void generateOdt() throws Exception { File in = getTestFile("text.rst"); - File out = getOutputTestFile("jrst-RstToOdt.odt"); - JRST.generate(JRST.Format.ODT.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.ODT.name(), in, out, JRST.Overwrite.ALLTIME); } /* Does not work for 'text.rst', cause this message with rst2latex : @@ -157,10 +149,9 @@ public void generateLatex() throws Exception { File in = getTestFile("test4.rst"); - File out = getOutputTestFile("jrst-RstToLatex.tex"); - JRST.generate(JRST.Format.LATEX.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.LATEX.name(), in, out, JRST.Overwrite.ALLTIME); } /* Does not work for 'text.rst', the header causes an 'NotImplementedError' */ @@ -168,20 +159,18 @@ public void generateMan() throws Exception { File in = getTestFile("test4.rst"); - File out = getOutputTestFile("jrst-RstToMan.man"); - JRST.generate(JRST.Format.MAN.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.MAN.name(), in, out, JRST.Overwrite.ALLTIME); } @Test public void generateS5() throws Exception { File in = getTestFile("text.rst"); - File out = getOutputTestFile("jrst-RstToS5.s5"); - JRST.generate(JRST.Format.S5.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.S5.name(), in, out, JRST.Overwrite.ALLTIME); } @Test @@ -191,6 +180,6 @@ File out = getOutputTestFile("jrst-RstToPDF.pdf"); - JRST.generate(JRST.Format.PDF.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.TYPE_PDF, in, out, JRST.Overwrite.ALLTIME); } } \ No newline at end of file Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java 2012-05-04 15:41:03 UTC (rev 656) @@ -59,7 +59,7 @@ // log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + in.getPath()); // log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + out.getPath()); // out.deleteOnExit(); - JRST.generate(JRST.Format.HTML.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); // Must contains <div class="note"> Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java 2012-05-04 15:41:03 UTC (rev 656) @@ -54,7 +54,7 @@ File in = getBugTestFile("testImages21.rst"); File out = getOutputTestFile("jrst-testImages.html"); // out.deleteOnExit(); - JRST.generate(JRST.Format.HTML.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); assertTrue(content.indexOf("alt=\"alternate text\"") > 0); @@ -76,7 +76,7 @@ File in = getBugTestFile("testContent877.rst"); File out = getOutputTestFile("jrst-testContent.html"); // out.deleteOnExit(); - JRST.generate(JRST.Format.HTML.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); assertTrue(content.indexOf("Table des matières") > 0); @@ -92,7 +92,7 @@ File in = getBugTestFile("testContents.rst"); File out = getOutputTestFile("jrst-testContents.html"); // out.deleteOnExit(); - JRST.generate(JRST.Format.HTML.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); assertTrue(content.indexOf("<b>") > 0); Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java 2012-05-04 15:41:03 UTC (rev 656) @@ -56,7 +56,7 @@ File in = getBugTestFile("testLinks.rst"); File out = getOutputTestFile("jrst-testLinks.html"); - JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); assertTrue(content.indexOf("href=\"http://labs.libre-entreprise.org/tracker/?atid=113&group_id=8&func=browse\"") > 0); @@ -75,7 +75,7 @@ File in = getBugTestFile("testLinks1380.rst"); File out = getOutputTestFile("jrst-testLinks.html"); - JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); assertTrue(content.indexOf("nuiton's forge") > 0); @@ -93,7 +93,7 @@ File in = getBugTestFile("testTab1378.rst"); File out = getOutputTestFile("jrst-testTab1378.html"); - JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); Pattern pattern = Pattern.compile(".*<blockquote>.*du bla bla \u00E9l\u00E9mentaire.*</blockquote>.*", Pattern.DOTALL); @@ -111,7 +111,7 @@ File in = getBugTestFile("testOptionsList644.rst"); File out = getOutputTestFile("jrst-testOptionList644.html"); - JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); assertTrue(content.indexOf("<span class=\"option\">-a</span>") > 0); @@ -135,7 +135,7 @@ File in = getBugTestFile("testLinks.rst"); File out = getOutputTestFile("jrst-testLinks.html"); - JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); assertTrue(content.indexOf("echapement de lien1_") > 0); @@ -150,7 +150,7 @@ File in = getBugTestFile("testEmbeddedURIs.rst"); File out = getOutputTestFile("jrst-testEmbeddedURIs.html"); - JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); assertTrue(content.contains("href=\"http://www.python.org\"")); Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java 2012-05-04 08:52:38 UTC (rev 655) +++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java 2012-05-04 15:41:03 UTC (rev 656) @@ -54,7 +54,7 @@ File in = new File("src/test/resources/bugs/testNoSubtitle.rst"); File out = File.createTempFile("jrst-RstToHtml2", ".html"); // out.deleteOnExit(); - JRST.generate(JRST.Format.HTML.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); } /** @@ -68,9 +68,10 @@ File in = new File("src/test/resources/bugs/testNoContentSubtitles.rst"); File out = File.createTempFile("jrst-testNoContentSubtitles", ".html"); // out.deleteOnExit(); - JRST.generate(JRST.Format.HTML.name(), in, out, JRST.Overwrite.ALLTIME); + JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME); String content = FileUtils.readFileToString(out); Assert.assertTrue(content.indexOf("<h2>Prérequis</h2>") > 0); + //<h2 class="subtitle" id="prerequis">Prérequis</h2> } }
participants (1)
-
jpages@users.nuiton.org