working on new documentation framework for pyAgrum

parent a926af08
......@@ -92,6 +92,7 @@ include_directories (${PYTHON_INCLUDE_DIR})
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${AGRUM_SOURCE_DIR})
include_directories(BEFORE ${AGRUM_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/generated_files)
include_directories(BEFORE ${AGRUM_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/doc)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
include_directories (${SWIG_SOURCE_DIR})
......
DESTDIR=$(shell python -c "import os;import pyAgrum;print(os.path.dirname(pyAgrum.__file__))")
run:
swig -c++ -python -outdir $(DESTDIR) -py3 -I../../swig -I../../../src -I../../../build/release -I.. pyAgrum.i
cd sphinx && make html
......@@ -2,7 +2,10 @@ For Windows
===========
- install conda
- conda install sphinx swig cmake
- conda install sphinx swig make(?)
- git clone [aGrUM@gitlab]
- git checkout documentation/swigDoc
-
How to document
===============
http://www.sphinx-doc.org/en/stable/ext/example_numpy.html#example-numpy
%feature("docstring") gum::Arc
"
pyAgrum.Arc is the representation of an arc between two nodes represented by `int`s : the head and the tail.
Parameters
----------
tail : int
the tail
head : int
the head
A copy constructor is also available
Parameters
----------
src : :class: Arc
the Arc to copy
"
%feature("docstring") gum::Arc::tail
"
Returns
-------
int
the id of the tail node
"
%feature("docstring") gum::Arc::head
"
Returns
------
int
the id of the head node
"
%feature("docstring") gum::Arc::other
"
Parameters
----------
id : int
the nodeId of the head or the tail
Returns
------
int
the nodeId of the other node
"
%feature("docstring") gum::Arc::first
"
Returns
------
int
the nodeId of the first node of the arc (the tail)
"
%feature("docstring") gum::Arc::second
"
Returns
------
int
the nodeId of the second node of the arc (the head)
"
%feature("docstring") gum::BayesNet
"
C'est un fameux 3 mats
BayesNet represents a Bayesian Network.
Parameters
==========
......
......@@ -5,8 +5,8 @@
SPHINXOPTS = -c . -a -E -w sphinx_warnings.txt
SPHINXBUILD = python3 `which sphinx-build`
PAPER =
BUILDDIR = ../../../build/release/wrappers/pyAgrum/docs
AGRUMBUILDDIR = "{agrum}/build/release/wrappers/pyAgrum/docs"
BUILDDIR = ..
AGRUMBUILDDIR = $(BUILDIR)
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
......
Bayesian Network
================
The Bayesian Network is the main object of pyAgrum. A bayesian network is a probabilistic graphical model. It represents a joint distribution over a set of random variables. In pyAgrum, the variable are (for now) only discrete. A bayesian network use a directed acyclic graph (DAG) to represent conditional indepencies in the joint distribution. These conditional indepencies allow to factorize the joint distribution and then allow to compactly represent very large ones. Moreover, inference algorithms can also use this graph to speed up the computations. Finally, the bayesian networks can be learned from data.
Model
-----
.. autoclass:: pyAgrum.BayesNet
:members:
.. autoclass:: pyAgrum.pyAgrum.BayesNet_double
:members:
......
......@@ -45,10 +45,10 @@ extensions = [
#'sphinx.ext.coverage',
'sphinx.ext.napoleon'
] # Napoleon settings
napoleon_google_docstring = True
napoleon_google_docstring = False
napoleon_numpy_docstring = True
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_include_special_with_doc = False
napoleon_use_admonition_for_examples = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
......@@ -459,70 +459,6 @@ epub_exclude_files = ['search.html']
autodoc_member_order = 'bysource'
autoclass_content = 'both'
############################ TRANSLATER SWIG type #############
import re
gumReplaceList = [
('pyAgrum.pyAgrum','pyAgrum'),
('gum::Idx', 'int'),
('gum::Size', 'int'),
('gum::NodeId', 'int'),
('std::string', 'str'),
('str &', 'str'),
('gum::', 'pyAgrum.'),
('_double ', ' '),
('< double > *', ' '),
('< double >', ' '),
(' const ', ' '),
('std::', ''),
('const &', ' '),
('const *', ' '),
('\w+ self,', '')
]
dico = {re.escape(x): y for x, y in gumReplaceList}
pattern = re.compile('|'.join([re.escape(x) for x, _ in gumReplaceList]))
def substitution4swigautodoc(l):
if l is None:
return None
l1 = l
l2 = ""
while l1 != l2:
l2 = l1
l1 = pattern.sub(lambda m: dico[re.escape(m.group(0))], l1)
return l1
def process_docstring(app, what, name, obj, options, lines):
# loop through each line in the docstring and replace |class| with
# the classname
for i in range(len(lines)):
lines[i] = substitution4swigautodoc(lines[i])
def process_signature(app, what, name, obj, options, signature, return_annotation):
signature = substitution4swigautodoc(signature)
return_annotation = substitution4swigautodoc(return_annotation)
return signature, return_annotation
def skip(app, what, name, obj, skip, options):
exclusions = ('__weakref__', '__ne__', '__eq__', # special-members
'__doc__', '__module__', '__dict__', # undoc-members
'__swig_destroy__', '_s', # swig members
'__init__' , # swig-managed
'clone', # special members
)
exclude = name in exclusions
if exclude:
#print("####### {}.{} excluded ".format(obj,name))
return True
if skip:
return True
return None
autodoc_default_flags = ['members',
#'private-members',
#'special-members',
......@@ -530,6 +466,7 @@ autodoc_default_flags = ['members',
#'show-inheritance',
]
def setup(app):
app.connect('autodoc-process-docstring', process_docstring)
app.connect('autodoc-process-signature', process_signature)
app.connect("autodoc-skip-member", skip)
pass
#app.connect('autodoc-process-docstring', process_docstring)
#app.connect('autodoc-process-signature', process_signature)
#app.connect("autodoc-skip-member", skip)
%include "doc_Arc.i"
%include "doc_BayesNet.i"
......@@ -5,7 +5,7 @@ into Bayesian Networks. The module is mainly generated by the SWIG
interface generator."
%enddef
%module(docstring=DOCSTRING, directors="1") pyAgrum
%feature("autodoc", "3");
%feature("autodoc", "0");
#pragma SWIG nowarn=341,342 // The 'using' keyword in type aliasing is not fully supported yet.
#pragma SWIG nowarn=320 // Explicit template instantiation ignored.
......@@ -26,7 +26,7 @@ interface generator."
%pythoncode %{
import numpy
%}
%include "docs.i"
//////////////////////////////////////////////////////////////////
/* declaration of code modifiers for 'pythonification' of aGrUM */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment