mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-07 01:42:26 +00:00
Minor doc updates, fixes and improvements
In particular, removed code which no longer worked, made light theme easier on the eyes, added slight syntax highlightning, and fixed search for exact matches.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
body {
|
||||
font-family: 'Nunito', sans-serif;
|
||||
color: #333;
|
||||
background-color:#fff;
|
||||
background-color:#eee;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #42aaed;
|
||||
color: #329add;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ pre {
|
||||
font-family: 'Source Code Pro', monospace;
|
||||
padding: 8px;
|
||||
color: #567;
|
||||
background: #f0f4f8;
|
||||
background: #e0e4e8;
|
||||
border-radius: 0;
|
||||
overflow-x: auto;
|
||||
}
|
||||
@@ -30,14 +30,14 @@ table {
|
||||
}
|
||||
|
||||
table td {
|
||||
border-top: 1px solid #eee;
|
||||
border-top: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.horizontal {
|
||||
margin-bottom: 16px;
|
||||
list-style: none;
|
||||
background: #f0f4f8;
|
||||
background: #e0e4e8;
|
||||
border-radius: 4px;
|
||||
padding: 8px 16px;
|
||||
}
|
||||
@@ -118,14 +118,14 @@ button {
|
||||
font-size: 16px;
|
||||
padding: 8px;
|
||||
color: #000;
|
||||
background-color: #fff;
|
||||
border: 2px solid #42aaed;
|
||||
background-color: #f7f7f7;
|
||||
border: 2px solid #329add;
|
||||
transition-duration: 300ms;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #42aaed;
|
||||
color: #fff;
|
||||
background-color: #329add;
|
||||
color: #f7f7f7;
|
||||
}
|
||||
|
||||
/* https://www.w3schools.com/css/css_navbar.asp */
|
||||
@@ -143,7 +143,7 @@ ul.together li {
|
||||
ul.together li a {
|
||||
display: block;
|
||||
border-radius: 8px;
|
||||
background: #f0f4f8;
|
||||
background: #e0e4e8;
|
||||
padding: 4px 8px;
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ if (typeof prependPath !== 'undefined') {
|
||||
// Returns the penalty for finding the needle in the haystack
|
||||
// or -1 if the needle wasn't found at all.
|
||||
function find(haystack, needle) {
|
||||
if (needle.length == 0) {
|
||||
return true;
|
||||
if (haystack.indexOf(needle) != -1) {
|
||||
return 0;
|
||||
}
|
||||
var hi = 0;
|
||||
var ni = 0;
|
||||
|
||||
@@ -43,7 +43,6 @@ class DocsWriter:
|
||||
"""Writes the head part for the generated document,
|
||||
with the given title and CSS
|
||||
"""
|
||||
#
|
||||
self.title = title
|
||||
self.write(
|
||||
'''<!DOCTYPE html>
|
||||
|
||||
@@ -105,13 +105,14 @@ def _generate_index(root, folder, paths,
|
||||
filename = folder / (BOT_INDEX if bots_index else INDEX)
|
||||
with DocsWriter(root, filename, _get_path_for_type) as docs:
|
||||
# Title should be the current folder name
|
||||
docs.write_head(str(folder).title(),
|
||||
docs.write_head(str(folder).replace(os.path.sep, '/').title(),
|
||||
css_path=paths['css'],
|
||||
default_css=paths['default_css'])
|
||||
|
||||
docs.set_menu_separator(paths['arrow'])
|
||||
_build_menu(docs)
|
||||
docs.write_title(str(filename.parent.relative_to(root)).title())
|
||||
docs.write_title(str(filename.parent.relative_to(root))
|
||||
.replace(os.path.sep, '/').title())
|
||||
|
||||
if bots_index:
|
||||
docs.write_text('These are the methods that you may be able to '
|
||||
@@ -379,19 +380,18 @@ def _write_html_pages(root, tlobjects, methods, layer, input_res):
|
||||
'<code>telethon.errors</code>.')
|
||||
|
||||
docs.write_title('Example', id='examples')
|
||||
docs.write(
|
||||
'<pre>from telethon.sync import TelegramClient\n'
|
||||
'from telethon import functions, types\n'
|
||||
'\n'
|
||||
'with TelegramClient(name, api_id, api_hash) as client:\n'
|
||||
' result = client(')
|
||||
docs.write('''<pre>\
|
||||
<strong>from</strong> telethon.sync <strong>import</strong> TelegramClient
|
||||
<strong>from</strong> telethon <strong>import</strong> functions, types
|
||||
|
||||
<strong>with</strong> TelegramClient(name, api_id, api_hash) <strong>as</strong> client:
|
||||
result = client(''')
|
||||
tlobject.as_example(docs, indent=1)
|
||||
docs.write(')\n')
|
||||
if tlobject.result.startswith('Vector'):
|
||||
docs.write(
|
||||
' for x in result:\n'
|
||||
' print(x'
|
||||
)
|
||||
docs.write('''\
|
||||
<strong>for</strong> x <strong>in</strong> result:
|
||||
print(x''')
|
||||
else:
|
||||
docs.write(' print(result')
|
||||
if tlobject.result != 'Bool' \
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
import re
|
||||
|
||||
|
||||
def _fmt_strings(*dicts):
|
||||
for d in dicts:
|
||||
for k, v in d.items():
|
||||
if v in ('None', 'True', 'False'):
|
||||
d[k] = '<strong>{}</strong>'.format(v)
|
||||
else:
|
||||
d[k] = re.sub(
|
||||
r'([brf]?([\'"]).*\2)',
|
||||
lambda m: '<em>{}</em>'.format(m.group(1)),
|
||||
v
|
||||
)
|
||||
|
||||
|
||||
KNOWN_NAMED_EXAMPLES = {
|
||||
('message', 'string'): "'Hello there!'",
|
||||
('expires_at', 'date'): 'datetime.timedelta(minutes=5)',
|
||||
@@ -41,6 +54,8 @@ KNOWN_TYPED_EXAMPLES = {
|
||||
'InputPeer': "'username'"
|
||||
}
|
||||
|
||||
_fmt_strings(KNOWN_NAMED_EXAMPLES, KNOWN_TYPED_EXAMPLES)
|
||||
|
||||
SYNONYMS = {
|
||||
'InputUser': 'InputPeer',
|
||||
'InputChannel': 'InputPeer',
|
||||
|
||||
Reference in New Issue
Block a user