Пример #1
0
    def hhelp(self, line):
        """
        define ``%hhelp``, it displays the help for an object in HTML

        .. nbref::
            :title: hhelp

            The magic command is equivalent to::

                from pyquickhelper import docstring2html
                docstring2html(obj, format=format)

        .. versionadded:: 1.1
        """
        parser = self.get_parser(MagicFile.hhelp_parser, "hhelp")
        args = self.get_args(line, parser)

        if args is not None:
            obj = args.obj
            format = args.format
            nop = args.no_print
            if nop or format == "html":
                return docstring2html(obj, format=format)
            else:
                print(docstring2html(obj, format=format))
Пример #2
0
    def hhelp(self, line):
        """
        Define ``%hhelp``, it displays the help for an object in :epkg:`HTML`.

        .. nbref::
            :title: hhelp

            The magic command is equivalent to::

                from pyquickhelper import docstring2html
                docstring2html(obj, format=format)

        .. versionadded:: 1.1
        """
        parser = self.get_parser(MagicFile.hhelp_parser, "hhelp")
        args = self.get_args(line, parser)

        if args is not None:
            obj = args.obj
            format = args.format
            nop = args.no_print
            if nop or format == "html":
                return docstring2html(obj, format=format)
            else:
                print(docstring2html(obj, format=format))
        return None
Пример #3
0
    def test_htmlhelp(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        mg = MagicFile()
        mg.add_context({
            "file_tail": file_tail,
            "Database": Database,
            "text": 3
        })
        cmd = "-np -f rawhtml file_tail"
        res = mg.hhelp(cmd)
        if "<p>Extracts the first nbline of a file " not in res:
            raise Exception(res)
        res = mg.hhelp("-np -f rst file_tail")
        if ":param" in res:
            raise Exception(res)
        res = mg.hhelp("-np -f rawhtml Database")
        self.assertIn("SQL file which can be empty or not,", res)
        doc = docstring2html(Database.__init__, format="rawhtml")
        self.assertIn("it can also contain several files separated by", doc)
        fLOG("----------")
        res = mg.hhelp("-np -f rst Database.__init__")
        self.assertIn("it can also contain several files separated by", res)
        res = mg.hhelp("Database.__init__")
        self.assertTrue(res is not None)
        res = mg.hhelp("-np -f text Database.__init__")
        self.assertIn("it can also contain several files separated by", res)
        self.assertIn("@param", res)
Пример #4
0
    def test_htmlhelp(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        mg = MagicFile()
        mg.add_context(
            {"file_tail": file_tail, "Database": Database, "text": 3})
        cmd = "-np -f rawhtml file_tail"
        res = mg.hhelp(cmd)
        assert "<p>extracts the first nbline of a file " in res
        res = mg.hhelp("-np -f rst file_tail")
        assert ":param      threshold:" in res
        res = mg.hhelp("-np -f rawhtml Database")
        assert "SQL file which can be empty or not," in res
        doc = docstring2html(Database.__init__, format="rawhtml")
        assert "it can also contain several files separated by" in doc
        fLOG("----------")
        res = mg.hhelp("-np -f rst Database.__init__")
        assert "it can also contain several files separated by" in res
        res = mg.hhelp("Database.__init__")
        assert res is not None
        res = mg.hhelp("-np -f text Database.__init__")
        assert "it can also contain several files separated by" in res
        assert "@param" in res
Пример #5
0
    def test_htmlhelp(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        mg = MagicFile()
        mg.add_context({
            "file_tail": file_tail,
            "Database": Database,
            "text": 3
        })
        cmd = "-np -f rawhtml file_tail"
        res = mg.hhelp(cmd)
        assert "<p>extracts the first nbline of a file " in res
        res = mg.hhelp("-np -f rst file_tail")
        assert ":param      threshold:" in res
        res = mg.hhelp("-np -f rawhtml Database")
        assert "SQL file which can be empty or not," in res
        doc = docstring2html(Database.__init__, format="rawhtml")
        assert "it can also contain several files separated by" in doc
        fLOG("----------")
        res = mg.hhelp("-np -f rst Database.__init__")
        assert "it can also contain several files separated by" in res
        res = mg.hhelp("Database.__init__")
        assert res is not None
        res = mg.hhelp("-np -f text Database.__init__")
        assert "it can also contain several files separated by" in res
        assert "@param" in res
Пример #6
0
    def test_htmlhelp(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        mg = MagicFile()
        mg.add_context(
            {"file_tail": file_tail, "Database": Database, "text": 3})
        cmd = "-np -f rawhtml file_tail"
        res = mg.hhelp(cmd)
        if "<p>Extracts the first nbline of a file " not in res:
            raise Exception(res)
        res = mg.hhelp("-np -f rst file_tail")
        if ":param" in res:
            raise Exception(res)
        res = mg.hhelp("-np -f rawhtml Database")
        self.assertIn("SQL file which can be empty or not,", res)
        doc = docstring2html(Database.__init__, format="rawhtml")
        self.assertIn("it can also contain several files separated by", doc)
        fLOG("----------")
        res = mg.hhelp("-np -f rst Database.__init__")
        self.assertIn("it can also contain several files separated by", res)
        res = mg.hhelp("Database.__init__")
        self.assertTrue(res is not None)
        res = mg.hhelp("-np -f text Database.__init__")
        self.assertIn("it can also contain several files separated by", res)
        self.assertIn("@param", res)