diff options
author | Hans de Graaff <graaff@gentoo.org> | 2019-08-28 14:11:24 +0200 |
---|---|---|
committer | Hans de Graaff <graaff@gentoo.org> | 2019-08-28 14:11:53 +0200 |
commit | 2dab7aa15724cdad83fb524a4a12d857e42f1aac (patch) | |
tree | 911d5e0096b5d5e810601b920099094a0910ca85 /dev-ruby/rdoc | |
parent | dev-db/mysql-init-scripts: package requires acct-{user,group}/mysql (diff) | |
download | gentoo-2dab7aa15724cdad83fb524a4a12d857e42f1aac.tar.gz gentoo-2dab7aa15724cdad83fb524a4a12d857e42f1aac.tar.bz2 gentoo-2dab7aa15724cdad83fb524a4a12d857e42f1aac.zip |
dev-ruby/rdoc: port jquery fixes to our 5.x version
Package-Manager: Portage-2.3.69, Repoman-2.3.16
Signed-off-by: Hans de Graaff <graaff@gentoo.org>
Diffstat (limited to 'dev-ruby/rdoc')
-rw-r--r-- | dev-ruby/rdoc/files/rdoc-5.1.0-jquery.patch | 492 | ||||
-rw-r--r-- | dev-ruby/rdoc/rdoc-5.1.0-r1.ebuild | 98 |
2 files changed, 590 insertions, 0 deletions
diff --git a/dev-ruby/rdoc/files/rdoc-5.1.0-jquery.patch b/dev-ruby/rdoc/files/rdoc-5.1.0-jquery.patch new file mode 100644 index 000000000000..46166e90e5c1 --- /dev/null +++ b/dev-ruby/rdoc/files/rdoc-5.1.0-jquery.patch @@ -0,0 +1,492 @@ +From 03c737f3579de998fb8f5142f2c44c96428528dd Mon Sep 17 00:00:00 2001 +From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Tue, 27 Aug 2019 12:55:42 +0000 +Subject: [PATCH] Update rdoc version from 5.0.0 to 5.0.1. + +git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@67781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e +--- + lib/rdoc.rb | 2 +- + .../generator/template/darkfish/_head.rhtml | 7 +- + .../generator/template/darkfish/css/rdoc.css | 23 +++- + .../template/darkfish/js/darkfish.js | 122 ++++-------------- + .../generator/template/darkfish/js/search.js | 63 ++++----- + .../template/json_index/js/navigation.js | 44 +------ + .../template/json_index/js/searcher.js | 12 +- + version.h | 10 +- + 8 files changed, 98 insertions(+), 185 deletions(-) + +diff --git a/lib/rdoc/generator/template/darkfish/_head.rhtml b/lib/rdoc/generator/template/darkfish/_head.rhtml +index f308526823e2..8304310d4b34 100644 +--- a/lib/rdoc/generator/template/darkfish/_head.rhtml ++++ b/lib/rdoc/generator/template/darkfish/_head.rhtml +@@ -7,8 +7,11 @@ + var index_rel_prefix = "<%= rel_prefix %>/"; + </script> + +-<script src="<%= asset_rel_prefix %>/js/jquery.js"></script> +-<script src="<%= asset_rel_prefix %>/js/darkfish.js"></script> ++<script src="<%= asset_rel_prefix %>/js/navigation.js" defer></script> ++<script src="<%= asset_rel_prefix %>/js/search.js" defer></script> ++<script src="<%= asset_rel_prefix %>/js/search_index.js" defer></script> ++<script src="<%= asset_rel_prefix %>/js/searcher.js" defer></script> ++<script src="<%= asset_rel_prefix %>/js/darkfish.js" defer></script> + + <link href="<%= asset_rel_prefix %>/css/fonts.css" rel="stylesheet"> + <link href="<%= asset_rel_prefix %>/css/rdoc.css" rel="stylesheet"> +diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css +index 2f4dca7e0844..1bdb6e6223c1 100644 +--- a/lib/rdoc/generator/template/darkfish/css/rdoc.css ++++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css +@@ -9,6 +9,8 @@ + /* vim: ft=css et sw=2 ts=2 sts=2 */ + /* Base Green is: #6C8C22 */ + ++.hide { display: none !important; } ++ + * { padding: 0; margin: 0; } + + body { +@@ -48,6 +50,16 @@ h6:hover span { + display: inline; + } + ++h1:target, ++h2:target, ++h3:target, ++h4:target, ++h5:target, ++h6:target { ++ margin-left: -10px; ++ border-left: 10px solid #f1edba; ++} ++ + :link, + :visited { + color: #6C8C22; +@@ -441,7 +453,16 @@ main header h3 { + /* @group Method Details */ + + main .method-source-code { +- display: none; ++ max-height: 0; ++ overflow: hidden; ++ transition-duration: 200ms; ++ transition-delay: 0ms; ++ transition-property: all; ++ transition-timing-function: ease-in-out; ++} ++ ++main .method-source-code.active-menu { ++ max-height: 100vh; + } + + main .method-description .method-calls-super { +diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js +index 38f877ed4028..089813fcdef4 100644 +--- a/lib/rdoc/generator/template/darkfish/js/darkfish.js ++++ b/lib/rdoc/generator/template/darkfish/js/darkfish.js +@@ -8,6 +8,7 @@ + */ + + /* Provide console simulation for firebug-less environments */ ++/* + if (!("console" in window) || !("firebug" in console)) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; +@@ -16,41 +17,35 @@ if (!("console" in window) || !("firebug" in console)) { + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; + }; +- +- +-/** +- * Unwrap the first element that matches the given @expr@ from the targets and return them. +- */ +-$.fn.unwrap = function( expr ) { +- return this.each( function() { +- $(this).parents( expr ).eq( 0 ).after( this ).remove(); +- }); +-}; ++*/ + + + function showSource( e ) { + var target = e.target; +- var codeSections = $(target). +- parents('.method-detail'). +- find('.method-source-code'); +- +- $(target). +- parents('.method-detail'). +- find('.method-source-code'). +- slideToggle(); ++ while (!target.classList.contains('method-detail')) { ++ target = target.parentNode; ++ } ++ if (typeof target !== "undefined" && target !== null) { ++ target = target.querySelector('.method-source-code'); ++ } ++ if (typeof target !== "undefined" && target !== null) { ++ target.classList.toggle('active-menu') ++ } + }; + + function hookSourceViews() { +- $('.method-heading').click( showSource ); ++ document.querySelectorAll('.method-heading').forEach(function (codeObject) { ++ codeObject.addEventListener('click', showSource); ++ }); + }; + + function hookSearch() { +- var input = $('#search-field').eq(0); +- var result = $('#search-results').eq(0); +- $(result).show(); ++ var input = document.querySelector('#search-field'); ++ var result = document.querySelector('#search-results'); ++ result.classList.remove("initially-hidden"); + +- var search_section = $('#search-section').get(0); +- $(search_section).show(); ++ var search_section = document.querySelector('#search-section'); ++ search_section.classList.remove("initially-hidden"); + + var search = new Search(search_data, input, result); + +@@ -77,85 +72,14 @@ function hookSearch() { + } + + search.select = function(result) { +- var result_element = result.get(0); +- window.location.href = result_element.firstChild.firstChild.href; ++ console.log(result); ++ window.location.href = result.firstChild.firstChild.href; + } + + search.scrollIntoView = search.scrollInWindow; + }; + +-function highlightTarget( anchor ) { +- console.debug( "Highlighting target '%s'.", anchor ); +- +- $("a[name]").each( function() { +- if ( $(this).attr("name") == anchor ) { +- if ( !$(this).parent().parent().hasClass('target-section') ) { +- console.debug( "Wrapping the target-section" ); +- $('div.method-detail').unwrap( 'div.target-section' ); +- $(this).parent().wrap( '<div class="target-section"></div>' ); +- } else { +- console.debug( "Already wrapped." ); +- } +- } +- }); +-}; +- +-function highlightLocationTarget() { +- console.debug( "Location hash: %s", window.location.hash ); +- if ( ! window.location.hash || window.location.hash.length == 0 ) return; +- +- var anchor = window.location.hash.substring(1); +- console.debug( "Found anchor: %s; matching %s", anchor, "a[name=" + anchor + "]" ); +- +- highlightTarget( anchor ); +-}; +- +-function highlightClickTarget( event ) { +- console.debug( "Highlighting click target for event %o", event.target ); +- try { +- var anchor = $(event.target).attr( 'href' ).substring(1); +- console.debug( "Found target anchor: %s", anchor ); +- highlightTarget( anchor ); +- } catch ( err ) { +- console.error( "Exception while highlighting: %o", err ); +- }; +-}; +- +-function loadAsync(path, success, prefix) { +- $.ajax({ +- url: prefix + path, +- dataType: 'script', +- success: success, +- cache: true +- }); +-}; +- +-$(document).ready( function() { ++document.addEventListener('DOMContentLoaded', function() { + hookSourceViews(); +- highlightLocationTarget(); +- $('ul.link-list a').bind( "click", highlightClickTarget ); +- +- var search_scripts_loaded = { +- navigation_loaded: false, +- search_loaded: false, +- search_index_loaded: false, +- searcher_loaded: false, +- } +- +- var search_success_function = function(variable) { +- return (function (data, status, xhr) { +- search_scripts_loaded[variable] = true; +- +- if (search_scripts_loaded['navigation_loaded'] == true && +- search_scripts_loaded['search_loaded'] == true && +- search_scripts_loaded['search_index_loaded'] == true && +- search_scripts_loaded['searcher_loaded'] == true) +- hookSearch(); +- }); +- } +- +- loadAsync('js/navigation.js', search_success_function('navigation_loaded'), rdoc_rel_prefix); +- loadAsync('js/search.js', search_success_function('search_loaded'), rdoc_rel_prefix); +- loadAsync('js/search_index.js', search_success_function('search_index_loaded'), index_rel_prefix); +- loadAsync('js/searcher.js', search_success_function('searcher_loaded'), rdoc_rel_prefix); ++ hookSearch(); + }); +diff --git a/lib/rdoc/generator/template/darkfish/js/search.js b/lib/rdoc/generator/template/darkfish/js/search.js +index 60ac295e6cec..b558ca5b4f68 100644 +--- a/lib/rdoc/generator/template/darkfish/js/search.js ++++ b/lib/rdoc/generator/template/darkfish/js/search.js +@@ -1,29 +1,29 @@ + Search = function(data, input, result) { + this.data = data; +- this.$input = $(input); +- this.$result = $(result); ++ this.input = input; ++ this.result = result; + +- this.$current = null; +- this.$view = this.$result.parent(); ++ this.current = null; ++ this.view = this.result.parentNode; + this.searcher = new Searcher(data.index); + this.init(); + } + +-Search.prototype = $.extend({}, Navigation, new function() { ++Search.prototype = Object.assign({}, Navigation, new function() { + var suid = 1; + + this.init = function() { + var _this = this; + var observer = function(e) { +- switch(e.originalEvent.keyCode) { ++ switch(e.keyCode) { + case 38: // Event.KEY_UP + case 40: // Event.KEY_DOWN + return; + } +- _this.search(_this.$input[0].value); ++ _this.search(_this.input.value); + }; +- this.$input.keyup(observer); +- this.$input.click(observer); // mac's clear field ++ this.input.addEventListener('keyup', observer); ++ this.input.addEventListener('click', observer); // mac's clear field + + this.searcher.ready(function(results, isLast) { + _this.addResults(results, isLast); +@@ -34,7 +34,7 @@ Search.prototype = $.extend({}, Navigation, new function() { + } + + this.search = function(value, selectFirstMatch) { +- value = jQuery.trim(value).toLowerCase(); ++ value = value.trim().toLowerCase(); + if (value) { + this.setNavigationActive(true); + } else { +@@ -43,23 +43,23 @@ Search.prototype = $.extend({}, Navigation, new function() { + + if (value == '') { + this.lastQuery = value; +- this.$result.empty(); +- this.$result.attr('aria-expanded', 'false'); ++ this.result.innerHTML = ''; ++ this.result.setAttribute('aria-expanded', 'false'); + this.setNavigationActive(false); + } else if (value != this.lastQuery) { + this.lastQuery = value; +- this.$result.attr('aria-busy', 'true'); +- this.$result.attr('aria-expanded', 'true'); ++ this.result.setAttribute('aria-busy', 'true'); ++ this.result.setAttribute('aria-expanded', 'true'); + this.firstRun = true; + this.searcher.find(value); + } + } + + this.addResults = function(results, isLast) { +- var target = this.$result.get(0); ++ var target = this.result; + if (this.firstRun && (results.length > 0 || isLast)) { +- this.$current = null; +- this.$result.empty(); ++ this.current = null; ++ this.result.innerHTML = ''; + } + + for (var i=0, l = results.length; i < l; i++) { +@@ -70,25 +70,26 @@ Search.prototype = $.extend({}, Navigation, new function() { + + if (this.firstRun && results.length > 0) { + this.firstRun = false; +- this.$current = $(target.firstChild); +- this.$current.addClass('search-selected'); ++ this.current = target.firstChild; ++ this.current.classList.add('search-selected'); + } +- if (jQuery.browser.msie) this.$element[0].className += ''; ++ //TODO: ECMAScript ++ //if (jQuery.browser.msie) this.$element[0].className += ''; + +- if (isLast) this.$result.attr('aria-busy', 'false'); ++ if (isLast) this.result.setAttribute('aria-busy', 'false'); + } + + this.move = function(isDown) { +- if (!this.$current) return; +- var $next = this.$current[isDown ? 'next' : 'prev'](); +- if ($next.length) { +- this.$current.removeClass('search-selected'); +- $next.addClass('search-selected'); +- this.$input.attr('aria-activedescendant', $next.attr('id')); +- this.scrollIntoView($next[0], this.$view[0]); +- this.$current = $next; +- this.$input.val($next[0].firstChild.firstChild.text); +- this.$input.select(); ++ if (!this.current) return; ++ var next = isDown ? this.current.nextElementSibling : this.current.previousElementSibling; ++ if (next) { ++ this.current.classList.remove('search-selected'); ++ next.classList.add('search-selected'); ++ this.input.setAttribute('aria-activedescendant', next.getAttribute('id')); ++ this.scrollIntoView(next, this.view); ++ this.current = next; ++ this.input.value = next.firstChild.firstChild.text; ++ this.input.select(); + } + return true; + } +diff --git a/lib/rdoc/generator/template/json_index/js/navigation.js b/lib/rdoc/generator/template/json_index/js/navigation.js +index e41268123ea9..4866fff81922 100644 +--- a/lib/rdoc/generator/template/json_index/js/navigation.js ++++ b/lib/rdoc/generator/template/json_index/js/navigation.js +@@ -10,10 +10,8 @@ Navigation = new function() { + this.initNavigation = function() { + var _this = this; + +- $(document).keydown(function(e) { ++ document.addEventListener('keydown', function(e) { + _this.onkeydown(e); +- }).keyup(function(e) { +- _this.onkeyup(e); + }); + + this.navigationActive = true; +@@ -21,20 +19,6 @@ Navigation = new function() { + + this.setNavigationActive = function(state) { + this.navigationActive = state; +- this.clearMoveTimeout(); +- } +- +- this.onkeyup = function(e) { +- if (!this.navigationActive) return; +- +- switch(e.keyCode) { +- case 37: //Event.KEY_LEFT: +- case 38: //Event.KEY_UP: +- case 39: //Event.KEY_RIGHT: +- case 40: //Event.KEY_DOWN: +- this.clearMoveTimeout(); +- break; +- } + } + + this.onkeydown = function(e) { +@@ -46,7 +30,6 @@ Navigation = new function() { + case 38: //Event.KEY_UP: + if (e.keyCode == 38 || e.ctrlKey) { + if (this.moveUp()) e.preventDefault(); +- this.startMoveTimeout(false); + } + break; + case 39: //Event.KEY_RIGHT: +@@ -55,34 +38,15 @@ Navigation = new function() { + case 40: //Event.KEY_DOWN: + if (e.keyCode == 40 || e.ctrlKey) { + if (this.moveDown()) e.preventDefault(); +- this.startMoveTimeout(true); + } + break; + case 13: //Event.KEY_RETURN: +- if (this.$current) ++ if (this.current) + e.preventDefault(); +- this.select(this.$current); ++ this.select(this.current); + break; + } +- if (e.ctrlKey && e.shiftKey) this.select(this.$current); +- } +- +- this.clearMoveTimeout = function() { +- clearTimeout(this.moveTimeout); +- this.moveTimeout = null; +- } +- +- this.startMoveTimeout = function(isDown) { +- if (!$.browser.mozilla && !$.browser.opera) return; +- if (this.moveTimeout) this.clearMoveTimeout(); +- var _this = this; +- +- var go = function() { +- if (!_this.moveTimeout) return; +- _this[isDown ? 'moveDown' : 'moveUp'](); +- _this.moveTimout = setTimeout(go, 100); +- } +- this.moveTimeout = setTimeout(go, 200); ++ if (e.ctrlKey && e.shiftKey) this.select(this.current); + } + + this.moveRight = function() { +diff --git a/lib/rdoc/generator/template/json_index/js/searcher.js b/lib/rdoc/generator/template/json_index/js/searcher.js +index b3b1c58a0f38..e200a168b0f7 100644 +--- a/lib/rdoc/generator/template/json_index/js/searcher.js ++++ b/lib/rdoc/generator/template/json_index/js/searcher.js +@@ -51,20 +51,20 @@ Searcher.prototype = new function() { + + /* ----- Utilities ------ */ + function splitQuery(query) { +- return jQuery.grep(query.split(/(\s+|::?|\(\)?)/), function(string) { ++ return query.split(/(\s+|::?|\(\)?)/).filter(function(string) { + return string.match(/\S/); + }); + } + + function buildRegexps(queries) { +- return jQuery.map(queries, function(query) { ++ return queries.map(function(query) { + return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i'); + }); + } + + function buildHilighters(queries) { +- return jQuery.map(queries, function(query) { +- return jQuery.map(query.split(''), function(l, i) { ++ return queries.map(function(query) { ++ return query.split('').map(function(l, i) { + return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2); + }).join(''); + }); +@@ -221,9 +221,9 @@ Searcher.prototype = new function() { + } + + function triggerResults(results, isLast) { +- jQuery.each(this.handlers, function(i, fn) { ++ this.handlers.forEach(function(fn) { + fn.call(this, results, isLast) +- }) ++ }); + } + } diff --git a/dev-ruby/rdoc/rdoc-5.1.0-r1.ebuild b/dev-ruby/rdoc/rdoc-5.1.0-r1.ebuild new file mode 100644 index 000000000000..2b5d676f131b --- /dev/null +++ b/dev-ruby/rdoc/rdoc-5.1.0-r1.ebuild @@ -0,0 +1,98 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=5 +USE_RUBY="ruby24" + +RUBY_FAKEGEM_TASK_DOC="" +RUBY_FAKEGEM_DOCDIR="doc" +RUBY_FAKEGEM_EXTRADOC="History.rdoc README.rdoc RI.rdoc TODO.rdoc" + +RUBY_FAKEGEM_BINWRAP="" +RUBY_FAKEGEM_BINDIR="exe" + +inherit ruby-fakegem eutils + +DESCRIPTION="An extended version of the RDoc library from Ruby 1.8" +HOMEPAGE="https://github.com/rdoc/rdoc/" +SRC_URI="https://github.com/rdoc/rdoc/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="Ruby MIT" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" +SLOT="0" +IUSE="" + +RDEPEND+=">=app-eselect/eselect-ruby-20161226" + +RUBY_PATCHES=( "${FILESDIR}/${P}-jquery.patch" ) + +ruby_add_bdepend " + dev-ruby/kpeg + dev-ruby/racc + test? ( + dev-ruby/bundler + >=dev-ruby/minitest-5.8:5 + )" + +ruby_add_rdepend "dev-ruby/json:2" + +all_ruby_prepare() { + # Other packages also have use for a nonexistent directory, bug 321059 + sed -i -e 's#/nonexistent#/nonexistent_rdoc_tests#g' test/test_rdoc*.rb || die + + # Avoid unneeded dependency on bundler, bug 603696 + sed -i -e '/bundler/ s:^:#:' \ + -e 's/Bundler::GemHelper.gemspec.full_name/"rdoc"/' Rakefile || die + + # Remove test that is depending on the locale, which we can't garantuee. + sed -i -e '/def test_encode_with/,/^ end/ s:^:#:' test/test_rdoc_options.rb || die + + # Remove test depending on FEATURES=userpriv, bug 361959 + sed -i -e '/def test_check_files/,/^ end/ s:^:#:' test/test_rdoc_options.rb || die + + # Remove tests for code that is not included and not listed in Manifest.txt + rm -f test/test_rdoc_i18n_{locale,text}.rb \ + test/test_rdoc_generator_pot* || die + + # Removal is not included in the upstream patch + rm -f lib/rdoc/generator/template/darkfish/js/jquery.js || die +} + +all_ruby_compile() { + all_fakegem_compile + + if use doc ; then + ruby -Ilib -S exe/rdoc || die + fi +} + +each_ruby_compile() { + ${RUBY} -S rake generate || die +} + +each_ruby_test() { + ${RUBY} -Ilib:. -e 'gem "json", "~>2.0"; Dir["test/test_*.rb"].each{|f| require f}' || die +} + +all_ruby_install() { + all_fakegem_install + + for bin in rdoc ri; do + ruby_fakegem_binwrapper $bin /usr/bin/$bin-2 + + for version in $(ruby_get_use_implementations); do + version=`echo ${version} | cut -c 5-` + if use ruby_targets_ruby${version}; then + ruby_fakegem_binwrapper $bin /usr/bin/${bin}${version} + sed -i -e "1s/env ruby/ruby${version}/" \ + "${ED}/usr/bin/${bin}${version}" || die + fi + done + done +} + +pkg_postinst() { + if [[ ! -n $(readlink "${ROOT}"usr/bin/rdoc) ]] ; then + eselect ruby set $(eselect --brief --colour=no ruby show | head -n1) + fi +} |