Discussion:
[Python.NET] Better doc strings.
Brad Byrd
2011-03-28 17:44:36 UTC
Permalink
I'm trying to provide better documentation for some C# classes that are called from Python. Ideally, I'd like to markup my class in C#, either with the standard XML comments or with something like a [PythonDocAttribute], and have this documentation show up as the __doc__ string for the method or class in Python. That way, the clients of my wrapped objects will see nice tool-tips on my classes as they code away in their IDE.

So, is this easily done? Has anyone else crossed this bridge before? Does something already exist that would work before I start hacking on the Python.NET source?

(Also, are the archives of the list searchable somewhere? I just saw clickable-by-month archives, not searchable.)

Thanks,

Brad...

_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Mark McMahon
2011-03-30 04:02:00 UTC
Permalink
Hi Brad,

No idea regarding your coding problem :-/

But your searching problem is easy...
Google allows you to specify a 'site' to restrict searches to. The following will search the archives for "__doc__"
site:mail.python.org/pipermail/pythondotnet __doc__
(generating this URL)
http://www.google.com.sg/search?q=site%3Amail.python.org%2Fpipermail%2Fpythondotnet%2F+__doc

I guess other search engines may have something similar.

Hope that helps
Mark


-----Original Message-----
From: pythondotnet-bounces+mark.mcmahon=autodesk.com-+ZN9ApsXKcEdnm+***@public.gmane.org [mailto:pythondotnet-bounces+mark.mcmahon=autodesk.com-+ZN9ApsXKcEdnm+***@public.gmane.org] On Behalf Of Brad Byrd
Sent: Tuesday, March 29, 2011 1:45 AM
To: pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org
Subject: [Python.NET] Better doc strings.

I'm trying to provide better documentation for some C# classes that are called from Python. Ideally, I'd like to markup my class in C#, either with the standard XML comments or with something like a [PythonDocAttribute], and have this documentation show up as the __doc__ string for the method or class in Python. That way, the clients of my wrapped objects will see nice tool-tips on my classes as they code away in their IDE.

So, is this easily done? Has anyone else crossed this bridge before? Does something already exist that would work before I start hacking on the Python.NET source?

(Also, are the archives of the list searchable somewhere? I just saw clickable-by-month archives, not searchable.)

Thanks,

Brad...
Brad Byrd
2011-03-30 16:28:24 UTC
Permalink
Thanks, that did the trick for searching the archives. (I forgot that you could do that with Google.)

Unfortunately, it doesn't look like anyone else in the archives has asked this question before.

Brad...


-----Original Message-----
From: Mark McMahon [mailto:mark.mcmahon-1QkGJYM4wCNWk0Htik3J/***@public.gmane.org]
Sent: Tuesday, March 29, 2011 9:02 PM
To: Brad Byrd; pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org
Subject: RE: Better doc strings.

Hi Brad,

No idea regarding your coding problem :-/

But your searching problem is easy...
Google allows you to specify a 'site' to restrict searches to. The following will search the archives for "__doc__"
site:mail.python.org/pipermail/pythondotnet __doc__
(generating this URL)
http://www.google.com.sg/search?q=site%3Amail.python.org%2Fpipermail%2Fpythondotnet%2F+__doc

I guess other search engines may have something similar.

Hope that helps
Mark


-----Original Message-----
From: pythondotnet-bounces+mark.mcmahon=autodesk.com-+ZN9ApsXKcEdnm+***@public.gmane.org [mailto:pythondotnet-bounces+mark.mcmahon=autodesk.com-+ZN9ApsXKcEdnm+***@public.gmane.org] On Behalf Of Brad Byrd
Sent: Tuesday, March 29, 2011 1:45 AM
To: pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org
Subject: [Python.NET] Better doc strings.

I'm trying to provide better documentation for some C# classes that are called from Python. Ideally, I'd like to markup my class in C#, either with the standard XML comments or with something like a [PythonDocAttribute], and have this documentation show up as the __doc__ string for the method or class in Python. That way, the clients of my wrapped objects will see nice tool-tips on my classes as they code away in their IDE.

So, is this easily done? Has anyone else crossed this bridge before? Does something already exist that would work before I start hacking on the Python.NET source?

(Also, are the archives of the list searchable somewhere? I just saw clickable-by-month archives, not searchable.)

Thanks,

Brad...
Barton
2011-03-30 07:10:08 UTC
Permalink
1) That's a very interesting proposition... Currently, the python
wrapper seems to overwrite any public attributes named __doc__. I'd
suggest a change that only writes that attr on the wrapped object if it
doesn't already exist in order for C# classes to get __doc__ strings in
the sort term.
[PythonDocAttribute] seems like the best answer for the long term.

2) The PythonDotNet Archives
(http://mail.python.org/pipermail/pythondotnet/) gives an OK overview
when you click on the [Subject] for each month.
Post by Brad Byrd
I'm trying to provide better documentation for some C# classes that are called from Python. Ideally, I'd like to markup my class in C#, either with the standard XML comments or with something like a [PythonDocAttribute], and have this documentation show up as the __doc__ string for the method or class in Python. That way, the clients of my wrapped objects will see nice tool-tips on my classes as they code away in their IDE.
So, is this easily done? Has anyone else crossed this bridge before? Does something already exist that would work before I start hacking on the Python.NET source?
(Also, are the archives of the list searchable somewhere? I just saw clickable-by-month archives, not searchable.)
Thanks,
Brad...
_________________________________________________
http://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Barton
2011-04-17 18:35:37 UTC
Permalink
Nabble works really well. For the moment, still on old.nabble:
http://old.nabble.com/Python---pythondotnet-f2969.html
Post by Brad Byrd
(Also, are the archives of the list searchable somewhere? I just saw clickable-by-month archives, not searchable.)
Thanks,
Brad...
_________________________________________________
http://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Glenn Ramsey
2011-04-17 19:42:24 UTC
Permalink
You can also search with Google using site:mail.python.org/pipermail/pythondotnet/
Post by Barton
http://old.nabble.com/Python---pythondotnet-f2969.html
Post by Brad Byrd
(Also, are the archives of the list searchable somewhere? I just saw
clickable-by-month archives, not searchable.)
Thanks,
Brad...
_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Barton
2011-04-23 23:05:13 UTC
Permalink
I just pushed the initial DocStringAttribute mods to the trunk:

* Python.Runtime now exposes a public class called DocStringAttribute
with usage = AttributeTargets.All

* Decorating .NET classes and methods has passed initial tests on Mono.

### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;

namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {

[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}


## test.py ##
import clr
clr.AddReference("SimpleLibTest") # the name of the .NET or Mono assembly
import PinvokeTest
from PinvokeTest import Invoke # .NET or Mono namespace maps to a
python module
# so grab the class from there
using import
Invoke.WriteToFile('a') # Now call a method on the class
print "Function docstring:",
print Invoke.WriteToFile.__doc__
print "Class docstring:", Invoke.__doc__
i = Invoke()
print "Instance docstring:", i.__doc__



On 03/28/2011 10:44 AM, Brad Byrd wrote:
I'm trying to provide better documentation for some C# classes that are
called from Python. Ideally, I'd like to markup my class in C#, either
with the standard XML comments or with something like a
[PythonDocAttribute], and have this documentation show up as the __doc__
string for the method or class in Python. That way, the clients of my
wrapped objects will see nice tool-tips on my classes as they code away
in their IDE.

So, is this easily done? Has anyone else crossed this bridge before?
Does something already exist that would work before I start hacking on
the Python.NET source?

(Also, are the archives of the list searchable somewhere? I just saw
clickable-by-month archives, not searchable.)

Thanks,

Brad...

_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet

_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Tribble, Brett
2011-04-25 23:17:16 UTC
Permalink
Well done sir!

-----Original Message-----
From: pythondotnet-bounces+btribble=ea.com-+ZN9ApsXKcEdnm+***@public.gmane.org [mailto:pythondotnet-bounces+btribble=ea.com-+ZN9ApsXKcEdnm+***@public.gmane.org] On Behalf Of Barton
Sent: Saturday, April 23, 2011 4:05 PM
To: Brad Byrd
Cc: pythondotnet-+ZN9ApsXKcEdnm+***@public.gmane.org
Subject: Re: [Python.NET] Better doc strings.

I just pushed the initial DocStringAttribute mods to the trunk:

* Python.Runtime now exposes a public class called DocStringAttribute
with usage = AttributeTargets.All

* Decorating .NET classes and methods has passed initial tests on Mono.

### test.cs ##
using System;
using System.Runtime.InteropServices;
using Python.Runtime;

namespace PinvokeTest
{
[DocStringAttribute("Interface class to external functions.")]
public class Invoke {

[DocStringAttribute("External funtion simulation: WriteToFile(char)
will write a char to the terminal.")]
public static void WriteToFile(char arg) {
Console.WriteLine("Writing {0}", arg);
return;
}
}
}


## test.py ##
import clr
clr.AddReference("SimpleLibTest") # the name of the .NET or Mono assembly
import PinvokeTest
from PinvokeTest import Invoke # .NET or Mono namespace maps to a
python module
# so grab the class from there
using import
Invoke.WriteToFile('a') # Now call a method on the class
print "Function docstring:",
print Invoke.WriteToFile.__doc__
print "Class docstring:", Invoke.__doc__
i = Invoke()
print "Instance docstring:", i.__doc__



On 03/28/2011 10:44 AM, Brad Byrd wrote:
I'm trying to provide better documentation for some C# classes that are
called from Python. Ideally, I'd like to markup my class in C#, either
with the standard XML comments or with something like a
[PythonDocAttribute], and have this documentation show up as the __doc__
string for the method or class in Python. That way, the clients of my
wrapped objects will see nice tool-tips on my classes as they code away
in their IDE.

So, is this easily done? Has anyone else crossed this bridge before?
Does something already exist that would work before I start hacking on
the Python.NET source?

(Also, are the archives of the list searchable somewhere? I just saw
clickable-by-month archives, not searchable.)

Thanks,

Brad...

_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet

_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet

_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet

Loading...