Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
59dba381
Kaydet (Commit)
59dba381
authored
Eki 30, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a button to the code examples in the doc to show/hide the prompts and output.
üst
ef4e2fa1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
+57
-0
layout.html
Doc/tools/sphinxext/layout.html
+1
-0
copybutton.js
Doc/tools/sphinxext/static/copybutton.js
+56
-0
No files found.
Doc/tools/sphinxext/layout.html
Dosyayı görüntüle @
59dba381
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
{% endblock %}
{% endblock %}
{% block extrahead %}
{% block extrahead %}
<link
rel=
"shortcut icon"
type=
"image/png"
href=
"{{ pathto('_static/py.png', 1) }}"
/>
<link
rel=
"shortcut icon"
type=
"image/png"
href=
"{{ pathto('_static/py.png', 1) }}"
/>
<script
type=
"text/javascript"
src=
"{{ pathto('_static/copybutton.js', 1) }}"
></script>
{{ super() }}
{{ super() }}
{% endblock %}
{% endblock %}
{% block footer %}
{% block footer %}
...
...
Doc/tools/sphinxext/static/copybutton.js
0 → 100644
Dosyayı görüntüle @
59dba381
$
(
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 ouput'
;
var
show_text
=
'Show the prompts and ouput'
;
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'
}
// 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
);
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'
).
toggle
(
function
()
{
var
button
=
$
(
this
);
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
);
},
function
()
{
var
button
=
$
(
this
);
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
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment