Skip to content

Commit 728e60f

Browse files
committed
Apply to the Library Fundamentals TS Working Paper the Proposed Wording from N3916, "Polymorphic Memory Resources"
This includes a big update to the html-doc-framework to support the changes.
1 parent 19e598b commit 728e60f

23 files changed

+6451
-1037
lines changed

Diff for: PooledResourcesImage.png

82.3 KB
Loading

Diff for: bower_components/cxx-html-doc-framework/.bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
"dependencies": {
1313
"polymer-ajax": "Polymer/polymer-ajax#0.2.0"
1414
},
15-
"_release": "7a8c0684ad",
15+
"_release": "23c55aa6ee",
1616
"_resolution": {
1717
"type": "branch",
1818
"branch": "master",
19-
"commit": "7a8c0684ad9796ff5da2b83f89cdc8379dcb12fa"
19+
"commit": "23c55aa6eec38c9796de104237bbf809cad95080"
2020
},
2121
"_source": "git://github.com/cplusplus/html-doc-framework.git",
2222
"_target": "*",

Diff for: bower_components/cxx-html-doc-framework/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ Contributor License Agreement at https://developers.google.com/open-source/cla/i
1919
Custom C++-specific elements
2020
----------------------------
2121

22+
Some of these elements define a `checkInvariants()` method, so you can run:
23+
24+
document.querySelectorAll('*').array().forEach(
25+
function(node){ if (node.checkInvariants) node.checkInvariants(); });
26+
27+
to see if you've gotten anything wrong.
28+
29+
### `<cxx-include href="other.html">`
30+
31+
This one isn't really C++-specific: it allows partitioning a main document
32+
into multiple pieces. `other.html`'s body will be copied in place of the
33+
`<cxx-include>` element.
34+
35+
2236
### `<cxx-clause>` and `<cxx-section>`
2337

2438
These automatically number clauses and sections, fill in

Diff for: bower_components/cxx-html-doc-framework/clause.html

+13-10
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,21 @@
1616
<polymer-element name="cxx-clause" extends="cxx-section">
1717
<script>
1818
(function() {
19-
var clause_num = 1;
19+
function updateTocClauses() {
20+
this.super();
21+
var toc = document.querySelector('cxx-toc');
22+
if (toc) {
23+
toc.clauses = document.querySelectorAll('cxx-clause');
24+
}
25+
}
2026
Polymer('cxx-clause', {
21-
attached: function() {
22-
this.super();
23-
var my_clause_num = clause_num++;
24-
25-
this.async(function() {
26-
// async() lets the descendant elements upgrade; after which we
27-
// need to traverse them to collect section numbers.
28-
this.update_sec_nums(my_clause_num);
29-
});
27+
// Convenience function at the clause level, which gets called from <cxx-toc>.
28+
set_clause_num: function(clause_num) {
29+
this.update_sec_nums(clause_num);
3030
},
31+
32+
attached: updateTocClauses,
33+
detached: updateTocClauses,
3134
});
3235
})();
3336
</script>

Diff for: bower_components/cxx-html-doc-framework/figure.html

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!-- Copyright 2014 Google Inc. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
-->
15+
16+
<!--
17+
Uses the HTML <figure> content model, but automatically adds a number to
18+
the <figcaption>.
19+
-->
20+
<polymer-element name="cxx-figure" constructor="CxxFigureElement">
21+
<template>
22+
<style>
23+
:host { margin-left: auto; margin-right: auto; }
24+
figcaption { white-space: nowrap; text-align: center; }
25+
/* @polyfill figcaption figcaption */
26+
::content figcaption { display: inline; }
27+
28+
</style>
29+
<figure>
30+
<figcaption>Figure {{figure_num}} — <wbr><content select="figcaption"></content></figcaption>
31+
<content></content>
32+
</figure>
33+
</template>
34+
<script>
35+
(function() {
36+
function renumberFigures() {
37+
document.querySelectorAll('cxx-figure').array().forEach(function(figure, index) {
38+
figure.figure_num = index + 1;
39+
});
40+
}
41+
Polymer('cxx-figure', {
42+
attached: renumberFigures,
43+
detached: renumberFigures,
44+
});
45+
})();
46+
</script>
47+
</polymer-element>

Diff for: bower_components/cxx-html-doc-framework/framework.html

+2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
<link rel="import" href="section.html"/>
2323
<link rel="import" href="clause.html"/>
2424
<link rel="import" href="table.html"/>
25+
<link rel="import" href="figure.html"/>
2526
<link rel="import" href="definition-section.html"/>
2627
<link rel="import" href="toc.html"/>
2728
<link rel="import" href="ref.html"/>
2829
<link rel="import" href="foreign-index.html"/>
2930
<link rel="import" href="titlepage.html"/>
31+
<script src="include.js"></script>
3032
<link rel="import" href="email.html"/>
3133
<link rel="import" href="ednote.html"/>
3234
<link rel="import" href="note.html"/>

Diff for: bower_components/cxx-html-doc-framework/function.html

+8
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@
6262
});
6363
</script>
6464
</polymer-element>
65+
<polymer-element name="cxx-preconditions" extends="cxx-attribute">
66+
<!-- This extension was introduced by N3916. -->
67+
<script>
68+
Polymer('cxx-preconditions', {
69+
heading: 'Preconditions',
70+
});
71+
</script>
72+
</polymer-element>
6573
<polymer-element name="cxx-effects" extends="cxx-attribute">
6674
<script>
6775
Polymer('cxx-effects', {

Diff for: bower_components/cxx-html-doc-framework/include.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* Copyright 2014 Google Inc. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
/* The <cxx-include href> element replaces itself with the contents at
17+
* 'href'. It doesn't use a shadow root so that the other document
18+
* acts exactly as part of the current document. */
19+
20+
(function() {
21+
"use strict";
22+
var includeProto = Object.create(HTMLElement.prototype);
23+
includeProto.attachedCallback = function() {
24+
this.link = document.createElement('link');
25+
this.link.setAttribute('rel', 'import');
26+
this.link.setAttribute('href', this.getAttribute('href'));
27+
this.link.onload = this.loaded.bind(this);
28+
this.link.onerror = function(e) {
29+
console.error(e);
30+
}
31+
document.head.appendChild(this.link);
32+
};
33+
includeProto.loaded = function(e) {
34+
var imported = this.link.import;
35+
this.link.parentNode.removeChild(this.link);
36+
var parent = this.parentNode;
37+
for (var elem = imported.body.firstChild; elem; elem = elem.nextSibling) {
38+
parent.insertBefore(elem.cloneNode(true), this);
39+
}
40+
parent.removeChild(this);
41+
};
42+
document.registerElement('cxx-include', {prototype: includeProto});
43+
})();

Diff for: bower_components/cxx-html-doc-framework/publish.js

+17
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,24 @@ limitations under the License.
6060
});
6161
}
6262

63+
function inlineImages(images) {
64+
Array.prototype.forEach.call(images,
65+
function(image) {
66+
if (image.naturalWidth == 0)
67+
console.error(image, "hasn't loaded yet.");
68+
var canvas = document.createElement('canvas');
69+
canvas.width = image.naturalWidth;
70+
canvas.height = image.naturalHeight;
71+
canvas.getContext('2d').drawImage(image, 0, 0, canvas.width, canvas.height);
72+
image.src = canvas.toDataURL();
73+
});
74+
}
75+
6376
function cloneStaticAndInline(doc) {
77+
// Inline the images on the source document instead of the copy
78+
// because the copy doesn't have time to load the images.
79+
inlineImages(doc.getElementsByTagName('img'));
80+
6481
var copy = doc.cloneNode(true);
6582
function removeAll(nodes) {
6683
forEach(nodes, function(node) {

Diff for: bower_components/cxx-html-doc-framework/ref.html

+10-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
limitations under the License.
1414
-->
1515

16+
<link rel="import" href="util/get-element-by-id.html"/>
17+
1618
<!--
1719
The 'to' attribute is the id of a <cxx-section> or <cxx-table> element (or subclass).
1820
@@ -27,13 +29,16 @@
2729

2830
<polymer-element name="cxx-ref" attributes="to insynopsis in">
2931
<template
32+
><cxx-get-element-by-id elemId="{{in}}" elem="{{inElem}}"></cxx-get-element-by-id
33+
><template if="{{!in}}"><cxx-get-element-by-id elemId="{{to}}" elem="{{toElem}}"></cxx-get-element-by-id></template
3034
><template id="target_num"
31-
><template if="{{in_elem.index}}">{{in_elem.name}} &#xa7;{{in_elem.index[to]}}</template
32-
><template if="{{!in}}"><a href="#{{to}}"
33-
><template if="{{to_elem.sec_num}}">{{to_elem.sec_num}}</template
34-
><template if="{{to_elem.table_num}}">Table {{to_elem.table_num}}</template></a></template
35+
><template if="{{inElem.index}}">{{inElem.name}} <span title="{{to}}">&#xa7;{{inElem.index[to]}}</span></template
36+
><template if="{{!in}}"><a title="{{to}}" href="#{{to}}"
37+
><template if="{{toElem.sec_num}}">{{toElem.sec_num}}</template
38+
><template if="{{toElem.table_num}}">Table {{toElem.table_num}}</template
39+
><template if="{{toElem.figure_num}}">Figure {{toElem.figure_num}}</template></a></template
3540
></template
36-
><template if="{{insynopsis}}">// <i><template bind="" ref="target_num"></template>, {{to_elem.title_element.textContent}}</i></template
41+
><template if="{{insynopsis}}">// <i><template bind="" ref="target_num"></template>, {{toElem.title_element.textContent}}</i></template
3742
><template if="{{!insynopsis}}"><template bind="" ref="target_num"></template></template
3843
></template>
3944
<script src="ref.js"></script>

Diff for: bower_components/cxx-html-doc-framework/ref.js

+32-21
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,53 @@ limitations under the License.
1919
insynopsis: false,
2020

2121
observe: {
22-
'in_elem.index': 'indexChanged'
22+
'inElem.index': 'indexChanged'
2323
},
2424
applyAuthorStyles: true,
2525

26-
inChanged: function() {
27-
this.in_elem = document.getElementById(this.in);
28-
if (this.in &&
29-
!(this.in_elem &&
30-
this.in_elem.tagName.toUpperCase() == 'CXX-FOREIGN-INDEX')) {
26+
checkInvariants: function() {
27+
if (this.in) {
28+
if (!this.inElem) {
29+
console.error(this, '.in (', this.in,
30+
') must refer to a <cxx-foreign-index> element.');
31+
}
32+
} else {
33+
if (!this.to) {
34+
console.error('<cxx-ref>', this,
35+
'must have an `in` or `to` attribute.');
36+
} else if (!this.toElem) {
37+
console.error(this, '.to (', this.to,
38+
') must refer to the ID of another element.');
39+
}
40+
}
41+
},
42+
43+
inElemChanged: function() {
44+
if (this.inElem &&
45+
this.inElem.tagName.toUpperCase() != 'CXX-FOREIGN-INDEX') {
3146
console.error('<cxx-ref>.in (', this.in,
3247
') must be a <cxx-foreign-index>; was',
33-
this.in_elem);
48+
this.inElem);
3449
}
3550
},
36-
toChanged: function() {
37-
if (!this.in) {
38-
this.to_elem = document.getElementById(this.to);
39-
if (!this.to_elem) {
40-
console.error("Broken link", this.to, "from", this);
41-
return;
42-
}
51+
toElemChanged: function() {
52+
if (this.toElem) {
4353
this.async(function() {
44-
// Async makes sure the to_elem is upgraded.
45-
if (!(this.to_elem instanceof CxxSectionElement ||
46-
this.to_elem instanceof CxxTableElement)) {
54+
// Async makes sure the toElem is upgraded.
55+
if (!(this.toElem instanceof CxxSectionElement ||
56+
this.toElem instanceof CxxTableElement ||
57+
this.toElem instanceof CxxFigureElement)) {
4758
console.error("Reference from", this,
48-
"refers to non-section, non-table element",
49-
this.to_elem);
59+
"refers to non-section, non-table, non-figure element",
60+
this.toElem);
5061
}
5162
});
5263
}
5364
},
5465

5566
indexChanged: function() {
56-
if (!(this.to in this.in_elem.index)) {
57-
console.error(this.to, 'not found in', this.in_elem);
67+
if (!(this.to in this.inElem.index)) {
68+
console.error(this.to, 'not found in', this.inElem);
5869
}
5970
}
6071
});

Diff for: bower_components/cxx-html-doc-framework/section.js

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ limitations under the License.
2020

2121
applyAuthorStyles: true,
2222

23+
checkInvariants: function() {
24+
if (!this.id) {
25+
console.error(this, 'is missing an id.');
26+
}
27+
},
28+
2329
update_sec_nums: function(sec_num) {
2430
this.sec_num = sec_num + '';
2531
var child_index = 1;

Diff for: bower_components/cxx-html-doc-framework/table.html

+7-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@
4040
</template>
4141
<script>
4242
(function() {
43-
var next_table_num = 1;
43+
function renumberTables() {
44+
document.querySelectorAll('[is=cxx-table]').array().forEach(function(table, index) {
45+
table.table_num = index + 1;
46+
});
47+
}
4448
Polymer('cxx-table', {
45-
created: function() {
46-
this.table_num = next_table_num++;
47-
}
49+
attached: renumberTables,
50+
detached: renumberTables,
4851
});
4952
})();
5053
</script>

Diff for: bower_components/cxx-html-doc-framework/toc.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ limitations under the License.
1515

1616
(function() {
1717
Polymer('cxx-toc', {
18-
// Hierarchy :: [{ elem: Element, sections: Hierarchy }]
18+
// Hierarchy :: [{ elem: Element, title: H1, sections: Hierarchy }]
1919
sections: [],
2020

21-
applyAuthorStyles: true,
21+
// Updated with the list of <cxx-clause> elements in the document each
22+
// time such an element is attached or detached.
23+
clauses: [],
2224

2325
collectSections: function(root) {
2426
var sections = [];
@@ -33,9 +35,15 @@ limitations under the License.
3335
sections: sections};
3436
},
3537

36-
created: function() {
37-
var clauses = window.document.querySelectorAll('cxx-clause');
38-
this.sections = clauses.array().map(this.collectSections, this);
38+
clausesChanged: function() {
39+
this.sections = this.clauses.array().map(function(clause, index) {
40+
clause.set_clause_num(index + 1);
41+
return this.collectSections(clause);
42+
}, this);
43+
},
44+
45+
attached: function() {
46+
this.clauses = document.querySelectorAll('cxx-clause');
3947
}
4048
})
4149
})();

0 commit comments

Comments
 (0)