@@ -158,8 +158,8 @@ def fix_doc(doc): # type: (Union[List[str], str]) -> str
158158
159159class RenderType (object ):
160160
161- def __init__ (self , toc , j , renderlist , redirects ):
162- # type: (ToC, List[Dict], str, Dict) -> None
161+ def __init__ (self , toc , j , renderlist , redirects , primitiveType ):
162+ # type: (ToC, List[Dict], str, Dict, str ) -> None
163163 self .typedoc = StringIO ()
164164 self .toc = toc
165165 self .subs = {} # type: Dict[str, str]
@@ -168,6 +168,7 @@ def __init__(self, toc, j, renderlist, redirects):
168168 self .rendered = set () # type: Set[str]
169169 self .redirects = redirects
170170 self .title = None # type: Optional[str]
171+ self .primitiveType = primitiveType
171172
172173 for t in j :
173174 if "extends" in t :
@@ -227,7 +228,6 @@ def typefmt(self,
227228 jsonldPredicate = None # type: Optional[Dict[str, str]]
228229 ):
229230 # type: (...) -> Union[str, unicode]
230- global primitiveType
231231 if isinstance (tp , list ):
232232 if nbsp and len (tp ) <= 3 :
233233 return " | " .join ([self .typefmt (n , redirects , jsonldPredicate = jsonldPredicate ) for n in tp ])
@@ -264,7 +264,7 @@ def typefmt(self,
264264 if str (tp ) in redirects :
265265 return """<a href="%s">%s</a>""" % (redirects [tp ], redirects [tp ])
266266 elif str (tp ) in basicTypes :
267- return """<a href="%s">%s</a>""" % (primitiveType , schema .avro_name (str (tp )))
267+ return """<a href="%s">%s</a>""" % (self . primitiveType , schema .avro_name (str (tp )))
268268 else :
269269 _ , frg = urlparse .urldefrag (tp )
270270 if frg is not '' :
@@ -277,6 +277,9 @@ def render_type(self, f, depth): # type: (Dict[str, Any], int) -> None
277277 return
278278 self .rendered .add (f ["name" ])
279279
280+ if f .get ("abstract" ):
281+ return
282+
280283 if "doc" not in f :
281284 f ["doc" ] = ""
282285
@@ -324,7 +327,7 @@ def extendsfrom(item, ex):
324327
325328 _ , frg = urlparse .urldefrag (f ["name" ])
326329 num = self .toc .add_entry (depth , frg )
327- doc = "## %s %s\n " % (num , frg )
330+ doc = "%s %s %s\n " % (( "#" * depth ), num , frg )
328331 else :
329332 doc = ""
330333
@@ -413,12 +416,12 @@ def extendsfrom(item, ex):
413416 self .render_type (self .typemap [s ], depth )
414417
415418
416- def avrold_doc (j , outdoc , renderlist , redirects , brand , brandlink ):
417- # type: (List[Dict[unicode, Any]], IO[Any], str, Dict, str, str) -> None
419+ def avrold_doc (j , outdoc , renderlist , redirects , brand , brandlink , primtype ):
420+ # type: (List[Dict[unicode, Any]], IO[Any], str, Dict, str, str, str ) -> None
418421 toc = ToC ()
419422 toc .start_numbering = False
420423
421- rt = RenderType (toc , j , renderlist , redirects )
424+ rt = RenderType (toc , j , renderlist , redirects , primtype )
422425 content = rt .typedoc .getvalue () # type: unicode
423426
424427 outdoc .write ("""
@@ -496,8 +499,7 @@ def avrold_doc(j, outdoc, renderlist, redirects, brand, brandlink):
496499 </html>""" )
497500
498501
499- if __name__ == "__main__" :
500-
502+ def main (): # type: () -> None
501503 parser = argparse .ArgumentParser ()
502504 parser .add_argument ("schema" )
503505 parser .add_argument ('--only' , action = 'append' )
@@ -526,10 +528,12 @@ def avrold_doc(j, outdoc, renderlist, redirects, brand, brandlink):
526528 s .append (j )
527529 else :
528530 raise ValueError ("Schema must resolve to a list or a dict" )
529-
530- primitiveType = args .primtype
531531 redirect = {}
532532 for r in (args .redirect or []):
533533 redirect [r .split ("=" )[0 ]] = r .split ("=" )[1 ]
534534 renderlist = args .only if args .only else []
535- avrold_doc (s , sys .stdout , renderlist , redirect , args .brand , args .brandlink )
535+ avrold_doc (s , sys .stdout , renderlist , redirect , args .brand , args .brandlink , args .primtype )
536+
537+
538+ if __name__ == "__main__" :
539+ main ()
0 commit comments