Skip to content

Commit 084e449

Browse files
committed
Preprocess: fix removal of See Also links
This fixes removal of See Also links between the C and C++ parts of the documentation.
1 parent 49f023a commit 084e449

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

commands/preprocess.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,17 @@ def remove_noprint(html):
257257
# remove see also links between C and C++ documentations
258258
def remove_see_also(html):
259259
for el in html.xpath('//tr[@class]'):
260-
if not has_class(el, 't-dcl-list-item'):
260+
if not has_class(el, 't-dcl-list-item', 't-dsc'):
261261
continue
262262

263263
child_tds = el.xpath('.//td/div[@class]')
264-
if not any(has_class(td, 't-dcl-list-see') for td in child_tds):
264+
if not any(has_class(td, 't-dcl-list-see', 't-dsc-see') for td in child_tds):
265265
continue
266266

267267
# remove preceding separator, if any
268268
prev = el.getprevious()
269269
if prev is not None:
270-
child_tds = prev.xpath('.//td[@class')
270+
child_tds = prev.xpath('.//td[@class]')
271271
if any(has_class(td, 't-dcl-list-sep') for td in child_tds):
272272
prev.getparent().remove(prev)
273273

@@ -280,19 +280,9 @@ def remove_see_also(html):
280280
next = el.getnext()
281281
if next is None:
282282
el.getparent().remove(el)
283-
continue
284-
285-
if next.tag != 'table':
286-
continue
287-
288-
if not has_class(next, 't-dcl-list-begin'):
289-
continue
290-
291-
if len(next.xpath('.//tr')) > 0:
292-
continue
293-
294-
el.getparent().remove(el)
295-
next.getparent().remove(next)
283+
elif next.tag == 'table' and has_class(next, 't-dcl-list-begin') and len(next.xpath('.//tr')) == 0:
284+
el.getparent().remove(el)
285+
next.getparent().remove(next)
296286

297287
# remove Google Analytics scripts
298288
def remove_google_analytics(html):

tests/preprocess_data/fabs_seealso.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,6 @@ <h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.
590590
<td> applies the function <span class="t-c"><span class="mw-geshi cpp source-cpp">std<span class="sy4">::</span><span class="me2">abs</span></span></span> to each element of valarray <br> <span class="t-mark">(function template)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/numeric/valarray/dsc_abs&amp;action=edit">[edit]</a></span>
591591
</td></tr>
592592

593-
<tr class="t-dsc">
594-
<td colspan="2"> <div class="t-dsc-see"><span><a href="../../../c/numeric/math/fabs.html" title="c/numeric/math/fabs">C documentation</a></span> for <span class="t-dsc-see-tt"><span>fabs</span></span></div>
595-
</td></tr>
596-
597593
</table>
598594

599595
<!--

0 commit comments

Comments
 (0)