eric6/UI/CodeDocumentationViewerTemplate.py

changeset 7264
bedbe458d792
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7263:c1af2e327675 7264:bedbe458d792
84 for char in ['=', ',', '(', ')', '*', '**']: 84 for char in ['=', ',', '(', ')', '*', '**']:
85 argspec = argspec.replace( 85 argspec = argspec.replace(
86 char, 86 char,
87 '<span class="argspec-highlight">{0}</span>'.format( 87 '<span class="argspec-highlight">{0}</span>'.format(
88 char)) 88 char))
89 argspec = argspecTemplate\ 89 argspec = (
90 .replace("@NAME@", name)\ 90 argspecTemplate
91 .replace("@NAME@", name)
91 .replace("@ARGSPEC@", argspec) 92 .replace("@ARGSPEC@", argspec)
93 )
92 else: 94 else:
93 argspec = argspecTemplate\ 95 argspec = (
94 .replace("@NAME@", name)\ 96 argspecTemplate
97 .replace("@NAME@", name)
95 .replace("@ARGSPEC@", "") 98 .replace("@ARGSPEC@", "")
99 )
96 100
97 if "typ" in documentationInfo and documentationInfo["typ"]: 101 if "typ" in documentationInfo and documentationInfo["typ"]:
98 typeInfo = typeTemplate.replace("@TYPE@", 102 typeInfo = typeTemplate.replace("@TYPE@",
99 documentationInfo["typ"]) 103 documentationInfo["typ"])
100 else: 104 else:
104 note = noteTemplate.replace("@NOTE@", 108 note = noteTemplate.replace("@NOTE@",
105 documentationInfo["note"]) 109 documentationInfo["note"])
106 else: 110 else:
107 note = "" 111 note = ""
108 112
109 metaData = metadataTemplate\ 113 metaData = (
110 .replace("@ARGSPEC@", argspec)\ 114 metadataTemplate
111 .replace("@TYPE@", typeInfo)\ 115 .replace("@ARGSPEC@", argspec)
116 .replace("@TYPE@", typeInfo)
112 .replace("@NOTE@", note) 117 .replace("@NOTE@", note)
113 118 )
114 header = headerTemplate\ 119
115 .replace("@TITLE@", title)\ 120 header = (
121 headerTemplate
122 .replace("@TITLE@", title)
116 .replace("@METADATA@", metaData) 123 .replace("@METADATA@", metaData)
124 )
117 else: 125 else:
118 header = "" 126 header = ""
119 127
120 if "docstring" in documentationInfo and documentationInfo["docstring"]: 128 if "docstring" in documentationInfo and documentationInfo["docstring"]:
121 docstring = documentationInfo["docstring"]\ 129 docstring = (
122 .replace("\r\n", "<br/>")\ 130 documentationInfo["docstring"]
123 .replace("\n", "<br/>")\ 131 .replace("\r\n", "<br/>")
132 .replace("\n", "<br/>")
124 .replace("\r", "<br/>") 133 .replace("\r", "<br/>")
134 )
125 docstring = docstringTemplate.replace("@DOCSTRING@", docstring) 135 docstring = docstringTemplate.replace("@DOCSTRING@", docstring)
126 else: 136 else:
127 docstring = \ 137 docstring = (
128 """<div class="hr"></div><div id="doc-warning">{0}</div>"""\ 138 """<div class="hr"></div><div id="doc-warning">{0}</div>"""
129 .format(QCoreApplication.translate( 139 .format(QCoreApplication.translate(
130 "CodeDocumentationViewer", 140 "CodeDocumentationViewer",
131 "No further documentation available")) 141 "No further documentation available"))
132 142 )
133 return mainTemplate\ 143
134 .replace("@HEADER@", header)\ 144 return (
145 mainTemplate
146 .replace("@HEADER@", header)
135 .replace("@DOCSTRING@", docstring) 147 .replace("@DOCSTRING@", docstring)
148 )
136 149
137 150
138 def prepareDocumentationViewerHtmlDocWarningDocument(text): 151 def prepareDocumentationViewerHtmlDocWarningDocument(text):
139 """ 152 """
140 Public function to prepare a HTML warning document. 153 Public function to prepare a HTML warning document.

eric ide

mercurial