49 """ |
49 """ |
50 |
50 |
51 metadataTemplate = """ |
51 metadataTemplate = """ |
52 <div class="metadata"> |
52 <div class="metadata"> |
53 @ARGSPEC@ |
53 @ARGSPEC@ |
|
54 @TYPE@ |
54 @NOTE@ |
55 @NOTE@ |
55 </div> |
56 </div> |
56 """ |
57 """ |
57 |
58 |
58 argspecTemplate = QCoreApplication.translate( |
59 argspecTemplate = QCoreApplication.translate( |
59 "CodeDocumentationViewer", |
60 "CodeDocumentationViewer", |
60 '<p><b>Definition:</b> <span class="def">@NAME@@ARGSPEC@</span></p>', |
61 '<p><b>Definition:</b> <span class="def">@NAME@@ARGSPEC@</span></p>', |
61 "Just translate 'Definition:' and leave the rest intact.") |
62 "Just translate 'Definition:' and leave the rest intact.") |
|
63 |
|
64 typeTemplate = QCoreApplication.translate( |
|
65 "CodeDocumentationViewer", |
|
66 "<p><b>Type:</b> @TYPE@</p>", |
|
67 "Just translate 'Type:' and leave the rest intact.") |
62 |
68 |
63 noteTemplate = QCoreApplication.translate( |
69 noteTemplate = QCoreApplication.translate( |
64 "CodeDocumentationViewer", |
70 "CodeDocumentationViewer", |
65 "<p><b>Note:</b> @NOTE@</p>", |
71 "<p><b>Note:</b> @NOTE@</p>", |
66 "Just translate 'Note:' and leave the rest intact.") |
72 "Just translate 'Note:' and leave the rest intact.") |
72 """ |
78 """ |
73 |
79 |
74 name = documentationInfo["name"] |
80 name = documentationInfo["name"] |
75 if name: |
81 if name: |
76 title = titleTemplate.replace("@NAME@", name) |
82 title = titleTemplate.replace("@NAME@", name) |
77 if documentationInfo["argspec"] or documentationInfo["note"]: |
83 if "argspec" in documentationInfo and documentationInfo["argspec"]: |
78 if documentationInfo["argspec"]: |
84 argspec = Utilities.html_encode(documentationInfo["argspec"]) |
79 argspec = Utilities.html_encode(documentationInfo["argspec"]) |
85 for char in ['=', ',', '(', ')', '*', '**']: |
80 for char in ['=', ',', '(', ')', '*', '**']: |
86 argspec = argspec.replace( |
81 argspec = argspec.replace( |
87 char, |
82 char, |
88 '<span class="argspec-highlight">{0}</span>'.format( |
83 '<span class="argspec-highlight">{0}</span>'.format( |
89 char)) |
84 char)) |
90 argspec = argspecTemplate\ |
85 argspec = argspecTemplate\ |
91 .replace("@NAME@", name)\ |
86 .replace("@NAME@", name)\ |
92 .replace("@ARGSPEC@", argspec) |
87 .replace("@ARGSPEC@", argspec) |
|
88 else: |
|
89 argspec = argspecTemplate\ |
|
90 .replace("@NAME@", name)\ |
|
91 .replace("@ARGSPEC@", "") |
|
92 if documentationInfo["note"]: |
|
93 note = noteTemplate.replace("@NOTE@", |
|
94 documentationInfo["note"]) |
|
95 else: |
|
96 note = "" |
|
97 metaData = metadataTemplate\ |
|
98 .replace("@ARGSPEC@", argspec)\ |
|
99 .replace("@NOTE@", note) |
|
100 else: |
93 else: |
101 metaData = "" |
94 argspec = argspecTemplate\ |
|
95 .replace("@NAME@", name)\ |
|
96 .replace("@ARGSPEC@", "") |
|
97 |
|
98 if "typ" in documentationInfo and documentationInfo["typ"]: |
|
99 typeInfo = typeTemplate.replace("@TYPE@", |
|
100 documentationInfo["typ"]) |
|
101 else: |
|
102 typeInfo = "" |
|
103 |
|
104 if "note" in documentationInfo and documentationInfo["note"]: |
|
105 note = noteTemplate.replace("@NOTE@", |
|
106 documentationInfo["note"]) |
|
107 else: |
|
108 note = "" |
|
109 |
|
110 metaData = metadataTemplate\ |
|
111 .replace("@ARGSPEC@", argspec)\ |
|
112 .replace("@TYPE@", typeInfo)\ |
|
113 .replace("@NOTE@", note) |
102 |
114 |
103 header = headerTemplate\ |
115 header = headerTemplate\ |
104 .replace("@TITLE@", title)\ |
116 .replace("@TITLE@", title)\ |
105 .replace("@METADATA@", metaData) |
117 .replace("@METADATA@", metaData) |
106 else: |
118 else: |
107 header = "" |
119 header = "" |
108 |
120 |
109 if documentationInfo["docstring"]: |
121 if "docstring" in documentationInfo and documentationInfo["docstring"]: |
110 docstring = documentationInfo["docstring"]\ |
122 docstring = documentationInfo["docstring"]\ |
111 .replace("\r\n", "<br/>")\ |
123 .replace("\r\n", "<br/>")\ |
112 .replace("\n", "<br/>")\ |
124 .replace("\n", "<br/>")\ |
113 .replace("\r", "<br/>") |
125 .replace("\r", "<br/>") |
114 docstring = docstringTemplate.replace("@DOCSTRING@", docstring) |
126 docstring = docstringTemplate.replace("@DOCSTRING@", docstring) |