Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach documentation to generated Tag Classes #18

Open
rgbkrk opened this issue Sep 29, 2017 · 2 comments
Open

Attach documentation to generated Tag Classes #18

rgbkrk opened this issue Sep 29, 2017 · 2 comments

Comments

@rgbkrk
Copy link
Member

rgbkrk commented Sep 29, 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:

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 legend
associated with a figure or an illustration described by the rest of
the 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!

@willingc
Copy link
Member

willingc commented Oct 9, 2017

We could even link straight to the MDN docs!

Cool!

@rgbkrk
Copy link
Member Author

rgbkrk commented Oct 26, 2017

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 rgbkrk changed the title Attaching documentation to generated Tag Classes Attach documentation to generated Tag Classes Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants