mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-04 19:52:28 +00:00
python-3.6.zip added from Github
README.cosmo contains the necessary links.
This commit is contained in:
parent
75fc601ff5
commit
0c4c56ff39
4219 changed files with 1968626 additions and 0 deletions
62
third_party/python/Doc/tools/static/copybutton.js
vendored
Normal file
62
third_party/python/Doc/tools/static/copybutton.js
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
$(document).ready(function() {
|
||||
/* Add a [>>>] button on the top-right corner of code samples to hide
|
||||
* the >>> and ... prompts and the output and thus make the code
|
||||
* copyable. */
|
||||
var div = $('.highlight-python .highlight,' +
|
||||
'.highlight-python3 .highlight')
|
||||
var pre = div.find('pre');
|
||||
|
||||
// get the styles from the current theme
|
||||
pre.parent().parent().css('position', 'relative');
|
||||
var hide_text = 'Hide the prompts and output';
|
||||
var show_text = 'Show the prompts and output';
|
||||
var border_width = pre.css('border-top-width');
|
||||
var border_style = pre.css('border-top-style');
|
||||
var border_color = pre.css('border-top-color');
|
||||
var button_styles = {
|
||||
'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0',
|
||||
'border-color': border_color, 'border-style': border_style,
|
||||
'border-width': border_width, 'color': border_color, 'text-size': '75%',
|
||||
'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em',
|
||||
'border-radius': '0 3px 0 0'
|
||||
}
|
||||
|
||||
// create and add the button to all the code blocks that contain >>>
|
||||
div.each(function(index) {
|
||||
var jthis = $(this);
|
||||
if (jthis.find('.gp').length > 0) {
|
||||
var button = $('<span class="copybutton">>>></span>');
|
||||
button.css(button_styles)
|
||||
button.attr('title', hide_text);
|
||||
button.data('hidden', 'false');
|
||||
jthis.prepend(button);
|
||||
}
|
||||
// tracebacks (.gt) contain bare text elements that need to be
|
||||
// wrapped in a span to work with .nextUntil() (see later)
|
||||
jthis.find('pre:has(.gt)').contents().filter(function() {
|
||||
return ((this.nodeType == 3) && (this.data.trim().length > 0));
|
||||
}).wrap('<span>');
|
||||
});
|
||||
|
||||
// define the behavior of the button when it's clicked
|
||||
$('.copybutton').click(function(e){
|
||||
e.preventDefault();
|
||||
var button = $(this);
|
||||
if (button.data('hidden') === 'false') {
|
||||
// hide the code output
|
||||
button.parent().find('.go, .gp, .gt').hide();
|
||||
button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
|
||||
button.css('text-decoration', 'line-through');
|
||||
button.attr('title', show_text);
|
||||
button.data('hidden', 'true');
|
||||
} else {
|
||||
// show the code output
|
||||
button.parent().find('.go, .gp, .gt').show();
|
||||
button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
|
||||
button.css('text-decoration', 'none');
|
||||
button.attr('title', hide_text);
|
||||
button.data('hidden', 'false');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
BIN
third_party/python/Doc/tools/static/py.png
vendored
Normal file
BIN
third_party/python/Doc/tools/static/py.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 695 B |
193
third_party/python/Doc/tools/static/sidebar.js
vendored
Normal file
193
third_party/python/Doc/tools/static/sidebar.js
vendored
Normal file
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* sidebar.js
|
||||
* ~~~~~~~~~~
|
||||
*
|
||||
* This script makes the Sphinx sidebar collapsible and implements intelligent
|
||||
* scrolling.
|
||||
*
|
||||
* .sphinxsidebar contains .sphinxsidebarwrapper. This script adds in
|
||||
* .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton used to
|
||||
* collapse and expand the sidebar.
|
||||
*
|
||||
* When the sidebar is collapsed the .sphinxsidebarwrapper is hidden and the
|
||||
* width of the sidebar and the margin-left of the document are decreased.
|
||||
* When the sidebar is expanded the opposite happens. This script saves a
|
||||
* per-browser/per-session cookie used to remember the position of the sidebar
|
||||
* among the pages. Once the browser is closed the cookie is deleted and the
|
||||
* position reset to the default (expanded).
|
||||
*
|
||||
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
// global elements used by the functions.
|
||||
// the 'sidebarbutton' element is defined as global after its
|
||||
// creation, in the add_sidebar_button function
|
||||
var jwindow = $(window);
|
||||
var jdocument = $(document);
|
||||
var bodywrapper = $('.bodywrapper');
|
||||
var sidebar = $('.sphinxsidebar');
|
||||
var sidebarwrapper = $('.sphinxsidebarwrapper');
|
||||
|
||||
// original margin-left of the bodywrapper and width of the sidebar
|
||||
// with the sidebar expanded
|
||||
var bw_margin_expanded = bodywrapper.css('margin-left');
|
||||
var ssb_width_expanded = sidebar.width();
|
||||
|
||||
// margin-left of the bodywrapper and width of the sidebar
|
||||
// with the sidebar collapsed
|
||||
var bw_margin_collapsed = '.8em';
|
||||
var ssb_width_collapsed = '.8em';
|
||||
|
||||
// colors used by the current theme
|
||||
var dark_color = '#AAAAAA';
|
||||
var light_color = '#CCCCCC';
|
||||
|
||||
function get_viewport_height() {
|
||||
if (window.innerHeight)
|
||||
return window.innerHeight;
|
||||
else
|
||||
return jwindow.height();
|
||||
}
|
||||
|
||||
function sidebar_is_collapsed() {
|
||||
return sidebarwrapper.is(':not(:visible)');
|
||||
}
|
||||
|
||||
function toggle_sidebar() {
|
||||
if (sidebar_is_collapsed())
|
||||
expand_sidebar();
|
||||
else
|
||||
collapse_sidebar();
|
||||
// adjust the scrolling of the sidebar
|
||||
scroll_sidebar();
|
||||
}
|
||||
|
||||
function collapse_sidebar() {
|
||||
sidebarwrapper.hide();
|
||||
sidebar.css('width', ssb_width_collapsed);
|
||||
bodywrapper.css('margin-left', bw_margin_collapsed);
|
||||
sidebarbutton.css({
|
||||
'margin-left': '0',
|
||||
'height': bodywrapper.height(),
|
||||
'border-radius': '5px'
|
||||
});
|
||||
sidebarbutton.find('span').text('»');
|
||||
sidebarbutton.attr('title', _('Expand sidebar'));
|
||||
document.cookie = 'sidebar=collapsed';
|
||||
}
|
||||
|
||||
function expand_sidebar() {
|
||||
bodywrapper.css('margin-left', bw_margin_expanded);
|
||||
sidebar.css('width', ssb_width_expanded);
|
||||
sidebarwrapper.show();
|
||||
sidebarbutton.css({
|
||||
'margin-left': ssb_width_expanded-12,
|
||||
'height': bodywrapper.height(),
|
||||
'border-radius': '0 5px 5px 0'
|
||||
});
|
||||
sidebarbutton.find('span').text('«');
|
||||
sidebarbutton.attr('title', _('Collapse sidebar'));
|
||||
//sidebarwrapper.css({'padding-top':
|
||||
// Math.max(window.pageYOffset - sidebarwrapper.offset().top, 10)});
|
||||
document.cookie = 'sidebar=expanded';
|
||||
}
|
||||
|
||||
function add_sidebar_button() {
|
||||
sidebarwrapper.css({
|
||||
'float': 'left',
|
||||
'margin-right': '0',
|
||||
'width': ssb_width_expanded - 28
|
||||
});
|
||||
// create the button
|
||||
sidebar.append(
|
||||
'<div id="sidebarbutton"><span>«</span></div>'
|
||||
);
|
||||
var sidebarbutton = $('#sidebarbutton');
|
||||
// find the height of the viewport to center the '<<' in the page
|
||||
var viewport_height = get_viewport_height();
|
||||
var sidebar_offset = sidebar.offset().top;
|
||||
var sidebar_height = Math.max(bodywrapper.height(), sidebar.height());
|
||||
sidebarbutton.find('span').css({
|
||||
'display': 'block',
|
||||
'position': 'fixed',
|
||||
'top': Math.min(viewport_height/2, sidebar_height/2 + sidebar_offset) - 10
|
||||
});
|
||||
|
||||
sidebarbutton.click(toggle_sidebar);
|
||||
sidebarbutton.attr('title', _('Collapse sidebar'));
|
||||
sidebarbutton.css({
|
||||
'border-radius': '0 5px 5px 0',
|
||||
'color': '#444444',
|
||||
'background-color': '#CCCCCC',
|
||||
'font-size': '1.2em',
|
||||
'cursor': 'pointer',
|
||||
'height': sidebar_height,
|
||||
'padding-top': '1px',
|
||||
'padding-left': '1px',
|
||||
'margin-left': ssb_width_expanded - 12
|
||||
});
|
||||
|
||||
sidebarbutton.hover(
|
||||
function () {
|
||||
$(this).css('background-color', dark_color);
|
||||
},
|
||||
function () {
|
||||
$(this).css('background-color', light_color);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function set_position_from_cookie() {
|
||||
if (!document.cookie)
|
||||
return;
|
||||
var items = document.cookie.split(';');
|
||||
for(var k=0; k<items.length; k++) {
|
||||
var key_val = items[k].split('=');
|
||||
var key = key_val[0];
|
||||
if (key == 'sidebar') {
|
||||
var value = key_val[1];
|
||||
if ((value == 'collapsed') && (!sidebar_is_collapsed()))
|
||||
collapse_sidebar();
|
||||
else if ((value == 'expanded') && (sidebar_is_collapsed()))
|
||||
expand_sidebar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_sidebar_button();
|
||||
var sidebarbutton = $('#sidebarbutton');
|
||||
set_position_from_cookie();
|
||||
|
||||
|
||||
/* intelligent scrolling */
|
||||
function scroll_sidebar() {
|
||||
var sidebar_height = sidebarwrapper.height();
|
||||
var viewport_height = get_viewport_height();
|
||||
var offset = sidebar.position()['top'];
|
||||
var wintop = jwindow.scrollTop();
|
||||
var winbot = wintop + viewport_height;
|
||||
var curtop = sidebarwrapper.position()['top'];
|
||||
var curbot = curtop + sidebar_height;
|
||||
// does sidebar fit in window?
|
||||
if (sidebar_height < viewport_height) {
|
||||
// yes: easy case -- always keep at the top
|
||||
sidebarwrapper.css('top', $u.min([$u.max([0, wintop - offset - 10]),
|
||||
jdocument.height() - sidebar_height - 200]));
|
||||
}
|
||||
else {
|
||||
// no: only scroll if top/bottom edge of sidebar is at
|
||||
// top/bottom edge of window
|
||||
if (curtop > wintop && curbot > winbot) {
|
||||
sidebarwrapper.css('top', $u.max([wintop - offset - 10, 0]));
|
||||
}
|
||||
else if (curtop < wintop && curbot < winbot) {
|
||||
sidebarwrapper.css('top', $u.min([winbot - sidebar_height - offset - 20,
|
||||
jdocument.height() - sidebar_height - 200]));
|
||||
}
|
||||
}
|
||||
}
|
||||
jwindow.scroll(scroll_sidebar);
|
||||
});
|
155
third_party/python/Doc/tools/static/switchers.js
vendored
Normal file
155
third_party/python/Doc/tools/static/switchers.js
vendored
Normal file
|
@ -0,0 +1,155 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
// Parses versions in URL segments like:
|
||||
// "3", "dev", "release/2.7" or "3.6rc2"
|
||||
var version_regexs = [
|
||||
'(?:\\d)',
|
||||
'(?:\\d\\.\\d[\\w\\d\\.]*)',
|
||||
'(?:dev)',
|
||||
'(?:release/\\d.\\d[\\x\\d\\.]*)'];
|
||||
|
||||
var all_versions = {
|
||||
'3.10': 'dev (3.10)',
|
||||
'3.9': 'pre (3.9)',
|
||||
'3.8': '3.8',
|
||||
'3.7': '3.7',
|
||||
'3.6': '3.6',
|
||||
'2.7': '2.7',
|
||||
};
|
||||
|
||||
var all_languages = {
|
||||
'en': 'English',
|
||||
'fr': 'French',
|
||||
'ja': 'Japanese',
|
||||
'ko': 'Korean',
|
||||
'pt-br': 'Brazilian Portuguese',
|
||||
};
|
||||
|
||||
function build_version_select(current_version, current_release) {
|
||||
var buf = ['<select>'];
|
||||
|
||||
$.each(all_versions, function(version, title) {
|
||||
buf.push('<option value="' + version + '"');
|
||||
if (version == current_version)
|
||||
buf.push(' selected="selected">' + current_release + '</option>');
|
||||
else
|
||||
buf.push('>' + title + '</option>');
|
||||
});
|
||||
|
||||
buf.push('</select>');
|
||||
return buf.join('');
|
||||
}
|
||||
|
||||
function build_language_select(current_language) {
|
||||
var buf = ['<select>'];
|
||||
|
||||
$.each(all_languages, function(language, title) {
|
||||
if (language == current_language)
|
||||
buf.push('<option value="' + language + '" selected="selected">' +
|
||||
all_languages[current_language] + '</option>');
|
||||
else
|
||||
buf.push('<option value="' + language + '">' + title + '</option>');
|
||||
});
|
||||
if (!(current_language in all_languages)) {
|
||||
// In case we're browsing a language that is not yet in all_languages.
|
||||
buf.push('<option value="' + current_language + '" selected="selected">' +
|
||||
current_language + '</option>');
|
||||
all_languages[current_language] = current_language;
|
||||
}
|
||||
buf.push('</select>');
|
||||
return buf.join('');
|
||||
}
|
||||
|
||||
function navigate_to_first_existing(urls) {
|
||||
// Navigate to the first existing URL in urls.
|
||||
var url = urls.shift();
|
||||
if (urls.length == 0) {
|
||||
window.location.href = url;
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: url,
|
||||
success: function() {
|
||||
window.location.href = url;
|
||||
},
|
||||
error: function() {
|
||||
navigate_to_first_existing(urls);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function on_version_switch() {
|
||||
var selected_version = $(this).children('option:selected').attr('value') + '/';
|
||||
var url = window.location.href;
|
||||
var current_language = language_segment_from_url(url);
|
||||
var current_version = version_segment_in_url(url);
|
||||
var new_url = url.replace('.org/' + current_language + current_version,
|
||||
'.org/' + current_language + selected_version);
|
||||
if (new_url != url) {
|
||||
navigate_to_first_existing([
|
||||
new_url,
|
||||
url.replace('.org/' + current_language + current_version,
|
||||
'.org/' + selected_version),
|
||||
'https://docs.python.org/' + current_language + selected_version,
|
||||
'https://docs.python.org/' + selected_version,
|
||||
'https://docs.python.org/'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
function on_language_switch() {
|
||||
var selected_language = $(this).children('option:selected').attr('value') + '/';
|
||||
var url = window.location.href;
|
||||
var current_language = language_segment_from_url(url);
|
||||
var current_version = version_segment_in_url(url);
|
||||
if (selected_language == 'en/') // Special 'default' case for english.
|
||||
selected_language = '';
|
||||
var new_url = url.replace('.org/' + current_language + current_version,
|
||||
'.org/' + selected_language + current_version);
|
||||
if (new_url != url) {
|
||||
navigate_to_first_existing([
|
||||
new_url,
|
||||
'https://docs.python.org/'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the path segment of the language as a string, like 'fr/'
|
||||
// or '' if not found.
|
||||
function language_segment_from_url(url) {
|
||||
var language_regexp = '\.org/([a-z]{2}(?:-[a-z]{2})?/)';
|
||||
var match = url.match(language_regexp);
|
||||
if (match !== null)
|
||||
return match[1];
|
||||
return '';
|
||||
}
|
||||
|
||||
// Returns the path segment of the version as a string, like '3.6/'
|
||||
// or '' if not found.
|
||||
function version_segment_in_url(url) {
|
||||
var language_segment = '(?:[a-z]{2}(?:-[a-z]{2})?/)';
|
||||
var version_segment = '(?:(?:' + version_regexs.join('|') + ')/)';
|
||||
var version_regexp = '\\.org/' + language_segment + '?(' + version_segment + ')';
|
||||
var match = url.match(version_regexp);
|
||||
if (match !== null)
|
||||
return match[1];
|
||||
return ''
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
var release = DOCUMENTATION_OPTIONS.VERSION;
|
||||
var language_segment = language_segment_from_url(window.location.href);
|
||||
var current_language = language_segment.replace(/\/+$/g, '') || 'en';
|
||||
var version = release.substr(0, 3);
|
||||
var version_select = build_version_select(version, release);
|
||||
|
||||
$('.version_switcher_placeholder').html(version_select);
|
||||
$('.version_switcher_placeholder select').bind('change', on_version_switch);
|
||||
|
||||
var language_select = build_language_select(current_language);
|
||||
|
||||
$('.language_switcher_placeholder').html(language_select);
|
||||
$('.language_switcher_placeholder select').bind('change', on_language_switch);
|
||||
});
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue