Difference between revisions of "MediaWiki talk:Gadget-standard revisions.js"
From cppreference.com
m |
(rejected chunks?) |
||
Line 205: | Line 205: | ||
{{cob}} | {{cob}} | ||
: --[[User:Space Mission|Space Mission]] ([[User talk:Space Mission|talk]]) 10:22, 20 October 2021 (PDT) | : --[[User:Space Mission|Space Mission]] ([[User talk:Space Mission|talk]]) 10:22, 20 October 2021 (PDT) | ||
+ | |||
+ | :: Hm, I'm not having much luck getting this patch to apply cleanly to the current version of this script. Is it based on an earlier version? [[User:Nate|Nate]] ([[User talk:Nate|talk]]) |
Revision as of 05:24, 21 October 2021
Contents |
This gadget doesn't work on "until/since C++03"
cppreference treats value initialization as a new feature in C++03, not a DR applied to C++98. But this gadget doesn't distinguish C++98/03 and it behaves unexpectedly on {{mark until c++03}} and its friends. --Fruderica (talk) 20:58, 4 May 2020 (PDT)
Do not list inapplicable revisions
- Some features are entirely new to a particular revision of the standard (e.g. CTAD which appeared in C++17). Selecting a preceding revision does not differ from selecting the revision that introduced the feature. (Strictly speaking, it should render the page empty.) Therefore, the preceding revisions should probably be left out.
- A succeeding revision that has no changes w.r.t the feature should probably be left out as well. This would prevent the reader from thinking that something was changed when in fact nothing actually was. As an alternative to leaving out, an explicit note can be added — e.g. "C++14 (no changes)".
Leaving out an item would also slightly simplify the interface (where possible). — Radix (talk) 03:41, 5 May 2020 (PDT)
Doesn't work on Vector skin
This can be resolved by replacingvar head_parent = $('#cpp-head-tools-right');
var head_parent; switch (mw.config.get('skin')) { case 'cppreference': case 'cppreference2': head_parent = $('#cpp-head-tools-right'); break; case 'vector': head_parent = $('#right-navigation'); break; default: return; }
Ojou (talk) 12:45, 10 August 2020 (PDT)
Add support for C++23 and C23
This should also be done this in other language versions. --Fruderica (talk) 22:42, 19 October 2021 (PDT)
- Here is the patch. It mostly adds the stuff like "C++23", "C17", and "C23", where appropriate. Except that, it also replaces the function
get_visibility_map_c
with a modified copy (adopted for "C") of the similar functionget_visibility_map_cxx
, to simplify the logic, since "C" now has more revisions.
A patch that adds support of C++23, C17, and C23 to the "Gadget-standard_revisions.js" |
---|
--- /tmp/Gadget-standard_revisions_OLD.js +++ /tmp/Gadget-standard_revisions_NEW.js @@ -68,11 +68,11 @@ /// Are we dealing with C or C++? var is_cxx = (mw.config.get('wgTitle').indexOf('c/') != 0); - // Standard revision identification 'enums'. Thoughout the plugin it is + // Standard revision identification 'enums'. Throughout the plugin it is // assumed that the values are integers starting at zero and thus they can // be used as an index in regular arrays. - var Rev_c = { DIFF: 0, FIRST: 1, C89: 1, C99: 2, C11: 3, LAST: 4 }; - var Rev_cxx = { DIFF: 0, FIRST: 1, CXX98: 1, CXX11: 2, CXX14: 3, CXX17: 4, CXX20: 5, LAST: 6 }; + var Rev_c = { DIFF: 0, FIRST: 1, C89: 1, C99: 2, C11: 3, C17: 4, C23: 5, LAST: 6 }; + var Rev_cxx = { DIFF: 0, FIRST: 1, CXX98: 1, CXX11: 2, CXX14: 3, CXX17: 4, CXX20: 5, CXX23: 6, LAST: 7 }; var Rev; @@ -88,6 +88,8 @@ { rev: Rev.C89, title: 'C89' }, { rev: Rev.C99, title: 'C99' }, { rev: Rev.C11, title: 'C11' }, + { rev: Rev.C17, title: 'C17' }, + { rev: Rev.C23, title: 'C23' }, ]; var desc_cxx = [ @@ -97,6 +99,7 @@ { rev: Rev.CXX14, title: 'C++14' }, { rev: Rev.CXX17, title: 'C++17' }, { rev: Rev.CXX20, title: 'C++20' }, + { rev: Rev.CXX23, title: 'C++23' }, ]; var desc; @@ -144,6 +147,9 @@ if (el.hasClass('t-since-cxx20')) { return { since: true, rev: Rev.CXX20 }; } + if (el.hasClass('t-since-cxx23')) { + return { since: true, rev: Rev.CXX23 }; + } if (el.hasClass('t-until-cxx11')) { return { since: false, rev: Rev.CXX11 }; } @@ -155,6 +161,9 @@ } if (el.hasClass('t-until-cxx20')) { return { since: false, rev: Rev.CXX20 }; + } + if (el.hasClass('t-until-cxx23')) { + return { since: false, rev: Rev.CXX23 }; } return { since: true, rev: Rev.CXX98 }; } @@ -166,11 +175,23 @@ if (el.hasClass('t-since-c11')) { return { since: true, rev: Rev.C11 }; } + if (el.hasClass('t-since-c17')) { + return { since: true, rev: Rev.C17 }; + } + if (el.hasClass('t-since-c23')) { + return { since: true, rev: Rev.C23 }; + } if (el.hasClass('t-until-c99')) { return { since: false, rev: Rev.C99 }; } if (el.hasClass('t-until-c11')) { return { since: false, rev: Rev.C11 }; + } + if (el.hasClass('t-until-c17')) { + return { since: false, rev: Rev.C17 }; + } + if (el.hasClass('t-until-c23')) { + return { since: false, rev: Rev.C23 }; } return { since: true, rev: Rev.C89 }; } @@ -295,12 +316,13 @@ included into the returned visibility map. */ function get_visibility_map_cxx(el) { - // DIFF: 0, CXX98: 1, CXX11: 2, CXX14: 3, CXX17: 4, CXX20: 5 + // DIFF: 0, CXX98: 1, CXX11: 2, CXX14: 3, CXX17: 4, CXX20: 5, CXX23: 6 var classes_cxx = [ { rev: Rev.CXX11, since: 't-since-cxx11', until: 't-until-cxx11' }, { rev: Rev.CXX14, since: 't-since-cxx14', until: 't-until-cxx14' }, { rev: Rev.CXX17, since: 't-since-cxx17', until: 't-until-cxx17' }, { rev: Rev.CXX20, since: 't-since-cxx20', until: 't-until-cxx20' }, + { rev: Rev.CXX23, since: 't-since-cxx23', until: 't-until-cxx23' }, ]; var map = new VisibilityMap(); for (var i = 0; i < classes_cxx.length; i++) { @@ -321,24 +343,35 @@ return map; } + /* This function is a modified copy of the previous one, adopted for "C". + * Space Mission. 2021/10/20. + */ function get_visibility_map_c(el) { - // DIFF: 0, C89: 1, C99: 2, C11: 3 - if (el.hasClass('t-since-c11')) { - return new VisibilityMap([Rev.C11]); - } - if (el.hasClass('t-since-c99')) { - if (el.hasClass('t-until-c11')) { - return new VisibilityMap([Rev.C99]); - } - return new VisibilityMap([Rev.C99, Rev.C11]); - } - if (el.hasClass('t-until-c99')) { - return new VisibilityMap([Rev.C89]); - } - if (el.hasClass('t-until-c11')) { - return new VisibilityMap([Rev.C89, Rev.C99]); - } - return new VisibilityMap([Rev.C89, Rev.C99, Rev.C11]); + // DIFF: 0, C89: 1, C99: 2, C11: 3, C17: 4, C23: 5 + var classes_c = [ + { rev: Rev.C89, since: 't-since-c89', until: 't-until-c89' }, + { rev: Rev.C99, since: 't-since-c99', until: 't-until-c99' }, + { rev: Rev.C11, since: 't-since-c11', until: 't-until-c11' }, + { rev: Rev.C17, since: 't-since-c17', until: 't-until-c17' }, + { rev: Rev.C23, since: 't-since-c23', until: 't-until-c23' }, + ]; + var map = new VisibilityMap(); + for (var i = 0; i < classes_c.length; i++) { + if (el.hasClass(classes_c[i].since)) { + break; + } + } + if (i === classes_c.length) { + map.add(Rev.C89); + i = 0; + } + for (; i < classes_c.length; i++) { + if (el.hasClass(classes_c[i].until)) { + break; + } + map.add(classes_c[i].rev); + } + return map; } var get_mark, get_visibility_map; @@ -1298,7 +1331,7 @@ return ret; }; - /** Returns infomation about the required copies of the base + /** Returns information about the required copies of the base element. */ function get_copy_info(visible, nums) { @@ -1639,7 +1672,7 @@ if (is_diff_clean) { // in case the Rev.DIFF version does not contain rev marks, then // we can reuse the objects for other revisions. Rev.DIFF version - // is fully visibily, so reflect that in the prev_visible array. + // is fully visibly, so reflect that in the prev_visible array. for (i = 0; i < visible_by_line.length; i++) { prev_visible.push(i); } @@ -1715,7 +1748,7 @@ }; /** Creates the standard revision selection menu in the page and registers - on_selection_change to be called whenever the seceltion changes. + on_selection_change to be called whenever the selection changes. */ StandardRevisionPlugin.prototype.create_selection_box = function() { var head_parent; |
- --Space Mission (talk) 10:22, 20 October 2021 (PDT)