Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upCan I only document the module itself? #15
Comments
This comment has been minimized.
This comment has been minimized.
|
I fully agree with your use case. There should absolutely be a way to limit the presence of ancestor classes in the documentation. I think the only thing that needs to be decided is how |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I have this working locally. My goal was to modify your code as little as possible. I found that the cleanest way to scope the objects being documented is to modify
I spent some time trying to see how to pass an argument to control this, looking at the docfilter argument for example. But it's not clear to me how to control this behavior with a command-line switch. I'm sure I could figure it out, but I'll bet you already know. :-) To me a working solution would be:
I was about to fork and submodule, but I'd much rather we achieve something like this, which adds value for everyone for what we agree seems like a reasonably common use case. I'm happy to pull request just the above change, or the entire patch including passing in the argument to control the behavior. Let me know what you think makes the most sense. (I might still fork because I'd like to customize the HTML template, but that is a separate issue.) Thanks! |
This comment has been minimized.
This comment has been minimized.
|
By the way here is a link to documentation created using |
This comment has been minimized.
This comment has been minimized.
|
I didn't read your answer carefully enough the first time. I can see the point of making this configurable per module and/or per class. That does complicate how you would tell pdoc how to document each module. The only thing I can think of, based on my knowledge of the system, is some kind of flag at the start of a module docstring or class docstring that you could parse for. If found you could put a key into the |
This comment has been minimized.
This comment has been minimized.
|
Any thoughts on how to proceed with this? |
This comment has been minimized.
This comment has been minimized.
|
Checking in one more time on this. Are you still interested in collaborating on a solution? |
This comment has been minimized.
This comment has been minimized.
|
@marksweiss Yes! Sorry about my absurd tardiness. How about you submit a PR for what you have and we (or I) can take it from there? As for class Something (object):
__pdoc__['Something__no-inherited-attributes'] = TrueThen it could be toggled per class. I think I might go for a global option too. |
This comment has been minimized.
This comment has been minimized.
mriehl
commented
Jan 22, 2015
|
Personally I don't think that completely disabling inherited attributes would be workable. I have a use case where the parent class is bloated with private methods but has a few methods I would like to expose. So I'm much more in favour of a whitelist/blacklist. For example some kind of
I thought about a decorator too but that would make it that much more difficult to document parent class behaviour. |
This comment has been minimized.
This comment has been minimized.
|
Sorry I never saw your response from last August. Do you still want a pull request? It should be simple unless there are many subsequent changes to merge in, as I'm working from a fork that is just this diff I needed to get this to work. @mriehl @BurntSushi I'm all for a more flexible approach, so again let me know if you want a pull request for my broader change. Thanks! |
This comment has been minimized.
This comment has been minimized.
|
@marksweiss I think I like @mriehl's suggested approach better. Reusing the concept of |
This comment has been minimized.
This comment has been minimized.
leotrs
commented
Feb 21, 2015
|
Hi, I tried using this solution found in #25 (which was closed in favor of this):
But didn't work. After this code, for some reason,
In which case Thanks. |
This comment has been minimized.
This comment has been minimized.
|
@Leockard Can you produce a minimal test case? It seems to be working fine over here: class A(object):
afoo = 1
def abaz(self):
pass
class B(A):
bfoo = 1
def bbaz(self):
passThen:
Now applying the __pdoc__ = {}
class A(object):
afoo = 1
def abaz(self):
pass
class B(A):
__pdoc__['B.k'] = None
for k in A.__dict__:
__pdoc__['B.%s' % k] = None
bfoo = 1
def bbaz(self):
passAnd the
|
This comment has been minimized.
This comment has been minimized.
leotrs
commented
Feb 21, 2015
|
OK, first, I thought the I'm using wxpython for my application. Here's the test code:
And the output:
Clearly, WindowToClientSize comes from wx.Frame. I have also tried
per your suggestion, but I get the same output. I finally got it to work by using:
Which outputs:
|
This comment has been minimized.
This comment has been minimized.
|
@Leockard Ah, great! So |
This comment has been minimized.
This comment has been minimized.
leotrs
commented
Feb 21, 2015
|
OK, by looking at it more closely, it looks like |
This comment has been minimized.
This comment has been minimized.
leotrs
commented
Feb 21, 2015
|
Well, setting everything in dir(base_class) to None didn't work either. For example,
Output:
Of course, since we are setting My workaround for now is to write something like this at the end of the file:
While I think this is still concise enough, I think this solution is approaching dangerous levels... EDIT: Of course, before doing |
This comment has been minimized.
This comment has been minimized.
dakov
commented
Mar 18, 2019
|
Is this really the only way to accomplish that? Don't you think it's a lot of overhead in cases with dozens of classes? For example, we want to generate a documentation for people who know very little programming. Therefore, we prepared many wrapper classes and methods for them to work with. So what I would need is to whitelist methods and attributes which will be reflected in the documentation, instead of black-listing those which will not. I'm a fan of the |
marksweiss commentedJul 26, 2014
I am very happy to find pdoc! I looked at other choices and they were heavy and poorly documented. So excellent to find something that works right away and is easy to manipulate.
That said, I have spent a few hours with the code but haven't quite figured out how to restrict the scope of documentation to just the contents of the module. I want to be able to only document:
A standard use case for this that I imagine isn't just mine is for unit tests. Including in the documentation all the methods inherited from UnitTest does not add useful information.
I think this applies generally for any situation where you want the documentation to only focus on the module source, rather than being comprehensive about all the context of that module. In my case, I am documenting an intentionally minimal library and a very strong design goal is keeping every aspect of it as brief and simple as possible.
I will happily provide a pull request if necessary to implement this.
Thanks!