epydoc friendlier formatting
[SVN r39368]
This commit is contained in:
parent
62ef542eaf
commit
8cfd3fb2ef
@ -543,10 +543,10 @@ void function::add_to_namespace(
|
||||
|
||||
if (docstring_options::show_cpp_signatures_)
|
||||
{
|
||||
if(len(_doc))
|
||||
_doc += "\n "+str(reinterpret_cast<const char*>(detail::cpp_signature_tag));
|
||||
else
|
||||
_doc += " "+str(reinterpret_cast<const char*>(detail::cpp_signature_tag));
|
||||
// if(len(_doc))
|
||||
// _doc += "\n"+str(reinterpret_cast<const char*>(detail::cpp_signature_tag));
|
||||
// else
|
||||
_doc += str(reinterpret_cast<const char*>(detail::cpp_signature_tag));
|
||||
}
|
||||
if(_doc)
|
||||
{
|
||||
@ -630,7 +630,7 @@ extern "C"
|
||||
list signatures = function_doc_signature_generator::function_doc_signatures(f);
|
||||
if(!signatures) return python::detail::none();
|
||||
signatures.reverse();
|
||||
return python::incref( str("\n ").join(signatures).ptr());
|
||||
return python::incref( str("\n").join(signatures).ptr());
|
||||
}
|
||||
|
||||
static int function_set_doc(PyObject* op, PyObject* doc, void*)
|
||||
|
@ -264,8 +264,8 @@ namespace boost { namespace python { namespace objects {
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
char py_signature_tag[] = "PY signature : ";
|
||||
char cpp_signature_tag[] = "C++ signature:";
|
||||
char py_signature_tag[] = "PY signature :";
|
||||
char cpp_signature_tag[] = "C++ signature :";
|
||||
}
|
||||
|
||||
list function_doc_signature_generator::function_doc_signatures( function const * f)
|
||||
@ -280,24 +280,43 @@ namespace boost { namespace python { namespace objects {
|
||||
if(*sfi == *fi){
|
||||
if((*fi)->doc()){
|
||||
str func_doc = str((*fi)->doc());
|
||||
int doc_len = len(func_doc);
|
||||
int doc_len = len(func_doc);
|
||||
bool show_py_signature = doc_len >=int(sizeof(detail::py_signature_tag)/sizeof(char)-1)
|
||||
&& str(detail::py_signature_tag)==func_doc.slice(0, int(sizeof(detail::py_signature_tag)/sizeof(char))-1);
|
||||
bool show_cpp_signature = doc_len >=int(sizeof(detail::cpp_signature_tag)/sizeof(char))
|
||||
if(show_py_signature){
|
||||
func_doc = str(func_doc.slice(int(sizeof(detail::py_signature_tag)/sizeof(char))-1, _));
|
||||
doc_len = len(func_doc);
|
||||
}
|
||||
|
||||
bool show_cpp_signature = doc_len >=int(sizeof(detail::cpp_signature_tag)/sizeof(char)-1)
|
||||
&& str(detail::cpp_signature_tag)==func_doc.slice(- int(sizeof(detail::cpp_signature_tag)/sizeof(char))+1, _);
|
||||
|
||||
str res;
|
||||
if(show_cpp_signature){
|
||||
func_doc = str(func_doc.slice(_, 1 - int(sizeof(detail::cpp_signature_tag)/sizeof(char))));
|
||||
doc_len = len(func_doc);
|
||||
}
|
||||
|
||||
str res="\n";
|
||||
str pad = "\n";
|
||||
if(show_py_signature)
|
||||
{
|
||||
str sig = pretty_signature(*fi, n_overloads,false);
|
||||
res+=sig;
|
||||
if(doc_len > int(sizeof(detail::py_signature_tag)/sizeof(char))-1 )
|
||||
res+=" : "+func_doc.slice(int(sizeof(detail::py_signature_tag)/sizeof(char))-1,_);
|
||||
}else
|
||||
res+=func_doc;
|
||||
if(doc_len || show_cpp_signature )res+=" :";
|
||||
pad+= str(" ");
|
||||
}
|
||||
|
||||
if(doc_len){
|
||||
if(show_py_signature)
|
||||
res+=pad;
|
||||
res+= pad.join(func_doc.split("\n"));
|
||||
}
|
||||
|
||||
if( show_cpp_signature)
|
||||
res+=str("\n ")+pretty_signature(*fi, n_overloads,true);
|
||||
if( show_cpp_signature){
|
||||
if(len(res)>1)
|
||||
res+="\n"+pad;
|
||||
res+=detail::cpp_signature_tag+pad+" "+pretty_signature(*fi, n_overloads,true);
|
||||
}
|
||||
|
||||
signatures.append(res);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user