From e05590249699ad6f0212d8acfd7ff09cd6bf4229 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Tue, 23 Apr 2019 13:33:57 -0400 Subject: [PATCH] Make doc a bit more complex --- c++/app4triqs/toto.hpp | 13 +++++++-- doc/conf.py.in | 2 +- doc/contents.rst | 12 ++++++++ python/app4triqs/toto_module_desc.py | 42 +++++++++++++++++++++++----- 4 files changed, 58 insertions(+), 11 deletions(-) diff --git a/c++/app4triqs/toto.hpp b/c++/app4triqs/toto.hpp index ea4f3052..4509e741 100644 --- a/c++/app4triqs/toto.hpp +++ b/c++/app4triqs/toto.hpp @@ -18,7 +18,7 @@ namespace app4triqs { /** * Construct from integer * - * @param i_ a scalar + * @param i_ a scalar :math:`G(\tau)` */ explicit toto(int i_) : i(i_) {} @@ -35,6 +35,13 @@ namespace app4triqs { /// Simple accessor int get_i() const { return i; } + /** + * A simple function with :math:`G(\tau)` + * + * @param u Nothing useful + */ + int f(int u) { return u;} + /// Arithmetic operations toto operator+(toto const &b) const; toto &operator+=(toto const &b); @@ -57,8 +64,8 @@ namespace app4triqs { * * Chain the decimal digits of two integers i and j, and return the result * - * @param :math:`i` The first integer - * @param :math:`j` The second integer + * @param i The first integer + * @param j The second integer * @return An integer containing the digits of both i and j * * @remark diff --git a/doc/conf.py.in b/doc/conf.py.in index ff1b11f9..4f7cb541 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -13,8 +13,8 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autosummary', - 'plot_directive', 'numpydoc', + 'plot_directive', 'autorun'] source_suffix = '.rst' diff --git a/doc/contents.rst b/doc/contents.rst index 217ae295..727af951 100644 --- a/doc/contents.rst +++ b/doc/contents.rst @@ -6,6 +6,12 @@ Documentation Contents -------- +.. math:: + + (a + b)^2 &= (a + b)(a + b) \\ + &= a^2 + 2ab + b^2 + + .. toctree:: :maxdepth: 5 @@ -15,6 +21,12 @@ Contents changelog about +Python +------ + +.. automodule:: app4triqs + :members: + Reference manual ---------------- diff --git a/python/app4triqs/toto_module_desc.py b/python/app4triqs/toto_module_desc.py index 859b72bc..e7eea446 100644 --- a/python/app4triqs/toto_module_desc.py +++ b/python/app4triqs/toto_module_desc.py @@ -1,5 +1,5 @@ # Generated automatically using the command : -# c++2py ../../c++/app4triqs/toto.hpp -p --members_read_only -N app4triqs -a app4triqs -m toto_module -o toto_module -C pytriqs --cxxflags="-std=c++17" +# c++2py ../../c++/app4triqs/toto.hpp -p --members_read_only -N app4triqs -a app4triqs -m toto_module -o toto_module -C pytriqs --cxxflags="-std=c++17 " from cpp2py.wrap_generator import * # The module @@ -24,20 +24,33 @@ using namespace app4triqs; c = class_( py_type = "Toto", # name of the python class c_type = "app4triqs::toto", # name of the C++ class - doc = """A very useful and important class\n\n @note A Useful note""", # doc of the C++ class + doc = r"""A very useful and important class""", # doc of the C++ class hdf5 = True, arithmetic = ("add_only"), comparisons = "==", serializable = "tuple" ) -c.add_constructor("""()""", doc = """""") +c.add_constructor("""()""", doc = r"""""") -c.add_constructor("""(int i_)""", doc = """Construct from integer\n\n :param i_: a scalar""") +c.add_constructor("""(int i_)""", doc = r"""Construct from integer + +Parameters +---------- +i_ + a scalar :math:`G(\tau)`""") + +c.add_method("""int f (int u)""", + doc = r"""A simple function with :math:`G(\tau)` + +Parameters +---------- +u + Nothing useful""") c.add_method("""std::string hdf5_scheme ()""", is_static = True, - doc = """HDF5""") + doc = r"""HDF5""") c.add_property(name = "i", getter = cfunction("int get_i ()"), @@ -45,8 +58,23 @@ c.add_property(name = "i", module.add_class(c) -module.add_function ("int app4triqs::chain (int i, int j)", doc = """Chain digits of two integers\n\n Chain the decimal digits of two integers i and j, and return the result\n\n @param :math:`i` The first integer\n @param :math:`j` The second integer\n @return An integer containing the digits of both i and j\n\n @remark""") +module.add_function ("int app4triqs::chain (int i, int j)", doc = r"""Chain digits of two integers + + Chain the decimal digits of two integers i and j, and return the result + +Parameters +---------- +i + The first integer + +j + The second integer + +Returns +------- +out + An integer containing the digits of both i and j""") -module.generate_code() \ No newline at end of file +module.generate_code()