mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Minor improvements to the template documentation dialog
* One string wasn't translated. * The "Show in English" box wasn't being respected for the "No documentation provided" message. * Documentation for stored templates wasn't formatted correctly
This commit is contained in:
parent
38e1645485
commit
ef6862da8b
@ -140,11 +140,16 @@ class DocViewer(Dialog):
|
|||||||
doc = func.doc if hasattr(func, 'doc') else ''
|
doc = func.doc if hasattr(func, 'doc') else ''
|
||||||
return doc.raw_text if self.english_cb.isChecked() and hasattr(doc, 'raw_text') else doc
|
return doc.raw_text if self.english_cb.isChecked() and hasattr(doc, 'raw_text') else doc
|
||||||
|
|
||||||
|
def no_doc_string(self):
|
||||||
|
if self.english_cb.isChecked():
|
||||||
|
return 'No documentation provided'
|
||||||
|
return _('No documentation provided')
|
||||||
|
|
||||||
def show_function(self, fname):
|
def show_function(self, fname):
|
||||||
self.last_operation = partial(self.show_function, fname)
|
self.last_operation = partial(self.show_function, fname)
|
||||||
bif = self.builtins[fname]
|
bif = self.builtins[fname]
|
||||||
if fname not in self.builtins or not bif.doc:
|
if fname not in self.builtins or not bif.doc:
|
||||||
self.set_html(self.header_line(fname) + ('No documentation provided'))
|
self.set_html(self.header_line(fname) + self.no_doc_string())
|
||||||
else:
|
else:
|
||||||
self.last_function = fname
|
self.last_function = fname
|
||||||
self.set_html(self.header_line(fname) +
|
self.set_html(self.header_line(fname) +
|
||||||
@ -162,11 +167,15 @@ class DocViewer(Dialog):
|
|||||||
try:
|
try:
|
||||||
doc = self.get_doc(self.builtins[name])
|
doc = self.get_doc(self.builtins[name])
|
||||||
if not doc:
|
if not doc:
|
||||||
a(_('No documentation provided'))
|
a(self.no_doc_string())
|
||||||
else:
|
else:
|
||||||
html = self.ffml.document_to_html(doc.strip(), name)
|
html = self.ffml.document_to_html(doc.strip(), name)
|
||||||
paren = html.find('(')
|
name_pos = html.find(name + '(')
|
||||||
html = f'<a href="ffdoc:{name}">{name}</a>{html[paren:]}'
|
if name_pos < 0:
|
||||||
|
rest_of_doc = ' -- ' + html
|
||||||
|
else:
|
||||||
|
rest_of_doc = html[name_pos + len(name):]
|
||||||
|
html = f'<a href="ffdoc:{name}">{name}</a>{rest_of_doc}'
|
||||||
a(html)
|
a(html)
|
||||||
except Exception:
|
except Exception:
|
||||||
print('Exception in', name)
|
print('Exception in', name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user