Esempio n. 1
0
    def test_use_cases_doc(self):
        """ Method to test the use cases rst documentation.
        """
        # Get all the use cases
        module_path = my_module.__path__[0]
        pilots = load_pilots(module_path, module_path, "capsul.sphinxext.test")
        self.assertTrue(len(pilots) == 1)
        self.assertTrue("capsul.sphinxext.test.test_usercases_doc" in pilots)
        self.assertTrue(len(pilots["capsul.sphinxext.test.test_usercases_doc"]) == 1)

        # Generate the writer object
        docwriter = UseCasesHelperWriter(pilots["capsul.sphinxext.test.test_usercases_doc"])
        rstdoc = docwriter.write_usecases_docs(returnrst=True)
        self.assertTrue("capsul.sphinxext.test.test_usercases_doc.pilot_dummy_test" in rstdoc)
Esempio n. 2
0
    def test_use_cases_doc(self):
        """ Method to test the use cases rst documentation.
        """
        # Get all the use cases
        module_path = my_module.__path__[0]
        pilots = load_pilots(module_path, module_path, "capsul.sphinxext.test")
        self.assertTrue(len(pilots) == 1)
        self.assertTrue("capsul.sphinxext.test.test_usercases_doc" in pilots)
        self.assertTrue(
            len(pilots["capsul.sphinxext.test.test_usercases_doc"]) == 1)

        # Generate the writer object
        docwriter = UseCasesHelperWriter(
            pilots["capsul.sphinxext.test.test_usercases_doc"])
        rstdoc = docwriter.write_usecases_docs(returnrst=True)
        self.assertTrue(
            "capsul.sphinxext.test.test_usercases_doc.pilot_dummy_test" in
            rstdoc)
Esempio n. 3
0
module_names = set([x.split(".")[1] for x in pilots])
# > sort each pilot according to its module name.
# > the result is a dict of the form 'd[m2] = [pilot1, ...]'
sorted_pilots = {}
for module_name, pilots in pilots.items():
    name = module_name.split(".")[1]
    sorted_pilots.setdefault(name, []).extend(pilots)

# Generate use cases reST
for module_name, pilots in sorted_pilots.items():

    # Where the documentation will be written: a relative path from the
    # makefile
    outdir = os.path.join(base_outdir, module_name, "use_cases")

    # Generate the writer object
    docwriter = UseCasesHelperWriter(pilots)
    docwriter.write_usecases_docs(outdir)

    # Create an index that will be inserted in the module main index.
    # The file format doesn't matter since we will make an include but prevent
    # Sphinx to convert such files
    docwriter.write_index(
        outdir, "index",
        relative_to=os.path.join(base_outdir, module_name),
        rst_extension=".txt")

    # Just print a summary
    logger.info("'{0}' files written for module '{1}'.".format(
        len(docwriter.written_usecases), module_name))
Esempio n. 4
0
module_names = set([x.split(".")[1] for x in pilots])
# > sort each pilot according to its module name.
# > the result is a dict of the form 'd[m2] = [pilot1, ...]'
sorted_pilots = {}
for module_name, pilots in pilots.items():
    name = module_name.split(".")[1]
    sorted_pilots.setdefault(name, []).extend(pilots)

# Generate use cases reST
for module_name, pilots in sorted_pilots.items():

    # Where the documentation will be written: a relative path from the
    # makefile
    outdir = os.path.join(base_outdir, module_name, "use_cases")

    # Generate the writer object
    docwriter = UseCasesHelperWriter(pilots)
    docwriter.write_usecases_docs(outdir)

    # Create an index that will be inserted in the module main index.
    # The file format doesn't matter since we will make an include but prevent
    # Sphinx to convert such files
    docwriter.write_index(outdir,
                          "index",
                          relative_to=os.path.join(base_outdir, module_name),
                          rst_extension=".txt")

    # Just print a summary
    logger.info("'{0}' files written for module '{1}'.".format(
        len(docwriter.written_usecases), module_name))