You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Libdoc specs: Argument name, type and default should be stored separately #3578
Currently Libdoc spec contain argument information so that possible type and default value are embedded to argument name. For example, if we have a keyword like
This is problematic if the consumer of the spec file wants to show only the argument name or is interested about the type or the default value for other reasons. Currently they need to split the argument info by using : and =, but this is extra work and also not fully safe as the default value and even the name can contain these characters as well. We need to store name, type and default separately but I'm not yet certain what's the best approach. Let's discuss about options in comments (or our Slack).
Related to this, we need to decide should we map the argument type info keywords provide to types we actually support. It is, fore example, possible to specify that an argument is an integer by using actual int type in Python, but also string Integer (case-insensitively) works in order to support dynamic API. Currently Libdoc spec files contain whatever the keyword provided and mapping to actually supported types is done at run time. Mapping types also in Libdoc spec files would have a benefit that spec consumers didn't need to support aliases like int and Integer. Not sure should this topic have its own issue.
Yet another thing to decide is showing varargs, kwargs and kw-only args. Currently we just have arguments like *varargs, **kws and * (kw-only separator) but could possibly specify this information somehow otherwise as well. That's highly related to deciding on the format how arguments are specified in general but probably needs a separate issue.
Name and type could also be attributes, but default value can contain newlines so it either needs to be an element or its value must he encoded to be able to safely use it as an attribute.
A problem with this approach is that it's quite badly backwards incompatible with the old format.
Another alternative is listing names and then mapping names to types and defaults separately. There are many possibilities for handling this mapping, but this is one possibility:
Current plan is, that the default XML will be incompatible with the previous Version.
It will become version 03.
There is already Version 01 and 02 (doc/schema/libdoc.02.xsd)
For backwards compatibility it shall be possible to generate legacyXML.
If reading of legacy XML is really needed is not yet clear.
legacy XML does not have all information the new libdoc model would require.
However it could be possible to parse arguments like argname:Type =default so stay compatible.
i wouldn’t assume that that is really needed.
imho the only case where this would be relevant, that someone has a "old" XML file somewhere and wants to create a html out of it. But the Library itself is not there anymore...
How realistic is this?
Activity
pekkaklarck commentedon May 22, 2020
One possibility how to separate name, type and default is grouping them together like this:
Name and type could also be attributes, but default value can contain newlines so it either needs to be an element or its value must he encoded to be able to safely use it as an attribute.
A problem with this approach is that it's quite badly backwards incompatible with the old format.
pekkaklarck commentedon May 22, 2020
Another alternative is listing names and then mapping names to types and defaults separately. There are many possibilities for handling this mapping, but this is one possibility:
This approach is to some extend compatible with the old format but I'm not sure is that so important.
Snooz82 commentedon Sep 15, 2020
Current plan is, that the default XML will be incompatible with the previous Version.
It will become version 03.
There is already Version 01 and 02 (
doc/schema/libdoc.02.xsd)For backwards compatibility it shall be possible to generate legacyXML.
If reading of legacy XML is really needed is not yet clear.
legacy XML does not have all information the new libdoc model would require.
However it could be possible to parse arguments like
argname:Type =defaultso stay compatible.i wouldn’t assume that that is really needed.
imho the only case where this would be relevant, that someone has a "old" XML file somewhere and wants to create a html out of it. But the Library itself is not there anymore...
How realistic is this?
Make ArgumentSpec iterable so that it yields ArgInfo objects
pekkaklarck commentedon Oct 20, 2020
Isn't this done now that #3720 has been merged?
Make ArgumentSpec iterable so that it yields ArgInfo objects