mirror of
https://github.com/hwchase17/langchain
synced 2024-10-31 15:20:26 +00:00
eb180e321f
can make it prettier, but what do we think of overall structure? https://api.python.langchain.com/en/dev2049-page_per_class/api_ref.html --------- Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: Nuno Campos <nuno@boringbits.io>
68 lines
2.6 KiB
HTML
68 lines
2.6 KiB
HTML
<script>
|
|
$(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,' +
|
|
'.highlight-pycon .highlight,' +
|
|
'.highlight-default .highlight')
|
|
var pre = div.find('pre');
|
|
|
|
// get the styles from the current theme
|
|
pre.parent().parent().css('position', 'relative');
|
|
var hide_text = 'Hide prompts and outputs';
|
|
var show_text = 'Show prompts and outputs';
|
|
|
|
// 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.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');
|
|
}
|
|
});
|
|
|
|
/*** Add permalink buttons next to glossary terms ***/
|
|
$('dl.glossary > dt[id]').append(function() {
|
|
return ('<a class="headerlink" href="#' +
|
|
this.getAttribute('id') +
|
|
'" title="Permalink to this term">¶</a>');
|
|
});
|
|
});
|
|
|
|
</script>
|
|
{%- if pagename != 'index' and pagename != 'documentation' %}
|
|
{% if theme_mathjax_path %}
|
|
<script id="MathJax-script" async src="{{ theme_mathjax_path }}"></script>
|
|
{% endif %}
|
|
{%- endif %}
|