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
Since #14, we've started generating documentation on the fly for the component helpers. We could take this another step if we want, changing createComponent like this:
diff --git a/vdom/core.py b/vdom/core.py
index 113a39f..a8a2e57 100644
--- a/vdom/core.py+++ b/vdom/core.py@@ -78,7 +78,7 @@ def _flatten_children(*children, **kwargs):
children = []
return children
-def createComponent(tagName):+def createComponent(tagName, doc=None):
"""Create a component for an HTML Tag
Examples:
@@ -101,12 +101,15 @@ def createComponent(tagName):
'text/plain': '<{tagName} />'.format(tagName=tagName)
}
- Component.__doc__ = """A virtual DOM component for a {tagName} tag-- >>> {tagName}()- <{tagName} />- """.format(tagName=tagName)-+ if doc:+ Component.__doc__ = doc+ else:+ Component.__doc__ = """A virtual DOM component for a {tagName} tag++ >>> {tagName}()+ <{tagName} />+ """.format(tagName=tagName)+
return Component
def createElement(tagName):
then in our helpers writing:
figcaption=createComponent(
'figcaption',
"""A virtual DOM component for <figcaption>. This tag represents a caption or a legendassociated with a figure or an illustration described by the rest ofthe data of the <figure> element which is its immediate ancestor.>>> figure(... img(src="http://bit.ly/storybot-vdom", alt="Storybot"),... figcaption('Fig1. Clickety clackety storybots')... )"""
Which would allow people to be able to explore the elements to figure out what's available to them.
help(figcaption)
We could even link straight to the MDN docs!
The text was updated successfully, but these errors were encountered:
Given how much the code has changed since I wrote the above, the approach might be different but I think we can still provide full examples for each element type along with a link to the MDN docs.
rgbkrk
changed the title
Attaching documentation to generated Tag Classes
Attach documentation to generated Tag Classes
Oct 27, 2017
Since #14, we've started generating documentation on the fly for the component helpers. We could take this another step if we want, changing
createComponent
like this:then in our helpers writing:
Which would allow people to be able to explore the elements to figure out what's available to them.
We could even link straight to the MDN docs!
The text was updated successfully, but these errors were encountered: