1. pygame
  2. pygame
  3. pygame

Source

pygame / makeref.py

Diff from to

File makeref.py

  • Ignore whitespace
     return files
 
 def Run():
+    
+    from optparse import OptionParser    
+    parser = OptionParser()
+    parser.add_option("", "--no-code-docs", dest="have_code_docs",
+                      action="store_false", default=True,
+                      help="No python documentation in code.")
+    (options, args) = parser.parse_args()
+
     files = collect_doc_files()
     for file in files:
         # print file
         HtmlOut(doc, index, outFile)
         outFile.write(HTMLFinish)
         outFile.close()
- 
-    outFile = open(os.path.join("src", "pygamedocs.h"), "w")
-    outFile.write("/* Auto generated file: with makeref.py .  Docs go in src/ *.doc . */\n")
-    for doc in justDocs:
-        WriteDocHeader(outFile, doc)
 
-
-    outFile.write("\n\n/* Docs in a comments... slightly easier to read. */\n\n\n/*")
-    # add the docs as comments to the header file.
-    for doc in justDocs:
+    for name, doc in docs:
+        outFile = open(os.path.join("src", "doc", "%s_doc.h") % name, "w")
+        outFile.write("/* Auto generated file: with makeref.py .  Docs go in src/ *.doc . */\n")
+        WriteDocHeader(outFile, doc, options.have_code_docs)
+        outFile.write("\n\n/* Docs in a comments... slightly easier to read. */\n\n\n/*")
         WriteDocHeaderComments(outFile, doc)
-
-    outFile.write("\n\n*/\n\n")
-
+        outFile.write("\n\n*/\n\n")
 
     topDoc = LayoutDocs(justDocs)
 
     f.write('\n\n<a name="%s">\n' % doc.fullname)
     f.write("<big><b>%s</big></b><br><ul>\n" % doc.fullname)
     if doc.descr:
-        f.write("  <i>%s</i><br>\n" % doc.descr) 
+        f.write("  <i>%s</i><br>\n" % doc.descr)
     if doc.protos:
         for p in doc.protos:
             f.write("  <tt>%s</tt><br>\n" % p)
 
 
 
-def WriteDocHeader(f, doc):
+def WriteDocHeader(f, doc, have_code_docs ):
     name = doc.fullname.replace(".", "")
     name = name.replace("_", "")
     name = name.upper()
     defineName = "DOC_" + name
     text = ""
-    if doc.protos:
-        text = "\\n".join(doc.protos)
-    if doc.descr:
-        if text:
-            text += "\\n"
-        text += doc.descr
+    if have_code_docs:
+        if doc.protos:
+            text = "\\n".join(doc.protos)
+        if doc.descr:
+            if text:
+                text += "\\n"
+            text += doc.descr
     
     f.write('#define %s "%s"\n\n' % (defineName, text))
 
     if doc.kids:
         for kid in doc.kids:
-            WriteDocHeader(f, kid)
+            WriteDocHeader(f, kid, have_code_docs)
 
 def WriteDocHeaderComments(f, doc):
     name = doc.fullname