Skip to content

Commit fbb3f8e

Browse files
committed
Make section number work correctly.
1 parent 452a6c6 commit fbb3f8e

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

clause.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@
2424
}
2525
}
2626
Polymer('cxx-clause', {
27-
// Convenience function at the clause level, which gets called from <cxx-toc>.
27+
28+
// Convenience function at the clause level, which gets called
29+
// from <cxx-toc>. If the clause is explicitly numbered, then
30+
// this sets the clause_num to that value. Otherwise, the clause
31+
// number is set to the argument clause_num. This returns
32+
// 1 + the value set.
33+
//
34+
// Note that this will recursively set the section numbers for
35+
// this clause.
2836
set_clause_num: function(clause_num) {
2937
// If the author explicitly specified the clause number, don't
3038
// use a different number.
3139
if (this.number)
32-
clause_num = this.number
40+
clause_num = Number(this.number)
3341
this.update_sec_nums(clause_num);
34-
return clause_num;
42+
return clause_num + 1;
3543
},
3644

3745
domReady: updateTocClauses,

section.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ limitations under the License.
3030
// Assume there aren't any elements between cxx-section levels.
3131
for (var child = this.firstChild; child; child = child.nextSibling) {
3232
if (child instanceof CxxSectionElement) {
33-
child.update_sec_nums(this.sec_num + '.' + (child_index++));
33+
if (child.number) {
34+
child_index = Number(child.number);
35+
console.log(child.number)
36+
}
37+
child.update_sec_nums(this.sec_num + '.' + child_index);
38+
child_index++;
3439
}
3540
}
3641
},

toc.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ limitations under the License.
3636
},
3737

3838
clausesChanged: function() {
39-
var n = 1
40-
while (n < this.clauses.length) {
41-
n = this.clause[n].set_clause_num(n)
39+
var clause_num = 1;
40+
for (var i = 0; i < this.clauses.length; ++i) {
41+
var clause = this.clauses[i];
42+
clause_num = clause.set_clause_num(clause_num);
43+
this.sections.push(this.collectSections(clause));
4244
}
4345

4446
// this.sections = this.clauses.array().map(function(clause, index) {

0 commit comments

Comments
 (0)