Skip to content

Commit

Permalink
Use a text-only summary for the description
Browse files Browse the repository at this point in the history
  • Loading branch information
danakj committed Sep 1, 2023
1 parent 34887c7 commit 2b75876
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>n::multiple - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Function with overloads&lt;/p&gt;"></meta>
<meta name="description" content="Function with overloads"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>n::multiple - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Separated overload&lt;/p&gt;"></meta>
<meta name="description" content="Separated overload"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
5 changes: 3 additions & 2 deletions subdoc/gen_tests/markdown/S.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>S - PROJECT NAME</title>
<meta name="description" content=""></meta>
<meta name="description" content="The summary has html tags in it."></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand All @@ -20,7 +20,6 @@
<a class="type-name" href="#">S</a>
</div>
<div class="type-signature">
<div class="template">template &lt;class T&gt;</div>
<span class="struct">
struct
</span>
Expand All @@ -32,6 +31,8 @@
</div>
</div>
<div class="description long">
<p>The <code>summary</code> has <b>html tags</b> in it.</p>

</div>
</div>
</div>
Expand Down
33 changes: 0 additions & 33 deletions subdoc/gen_tests/markdown/fn.return_template.html

This file was deleted.

18 changes: 1 addition & 17 deletions subdoc/gen_tests/markdown/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,7 @@
</div>
</div>
<div class="description short">
</div>
</li>
</ul>
</div>
<div class="section functions">
<div class="section-header">
Functions
</div>
<ul class="section-items item-table">
<li class="section-item">
<div class="overload-set item-name">
<div class="overload">
<div class="function-signature"><a class="function-name" href="fn.return_template.html">return_template</a></div>
</div>
</div>
<div class="description short">
<p>Returns template</p>
<p>The <code>summary</code> has <b>html tags</b> in it.</p>
</div>
</li>
</ul>
Expand Down
5 changes: 1 addition & 4 deletions subdoc/gen_tests/markdown/test.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// This tests a struct in the global namespace, and a struct in a private
// namespace. The former is generated and the latter is not.

template <class T>
/// The <code>summary</code> has <b>html tags</b> in it.
struct S {};

/// Returns template
S<int> return_template();
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>outer_namespace::outer - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Outer function&lt;/p&gt;"></meta>
<meta name="description" content="Outer function"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>outer_namespace::empty - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Empty namespace&lt;/p&gt;"></meta>
<meta name="description" content="Empty namespace"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>outer_namespace::inner_namespace::inner - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Inner function&lt;/p&gt;"></meta>
<meta name="description" content="Inner function"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>outer_namespace::inner_namespace - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Inner namespace&lt;/p&gt;"></meta>
<meta name="description" content="Inner namespace"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>outer_namespace - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Outer namespace&lt;/p&gt;"></meta>
<meta name="description" content="Outer namespace"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
2 changes: 1 addition & 1 deletion subdoc/gen_tests/struct-basic/S.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>S - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Comment headline S&lt;/p&gt;"></meta>
<meta name="description" content="Comment headline S"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
2 changes: 1 addition & 1 deletion subdoc/gen_tests/struct-complex/S.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<title>S - PROJECT NAME</title>
<meta name="description" content="&lt;p&gt;Comment headline S&lt;/p&gt;"></meta>
<meta name="description" content="Comment headline S"></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
</head>

Expand Down
19 changes: 19 additions & 0 deletions subdoc/gen_tests/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
Classes
</div>
<ul class="section-items item-table">
<li class="section-item">
<div class="item-name">
<div class="type-signature">
<a class="type-name" href="S.html">S</a>
</div>
</div>
<div class="description short">
</div>
</li>
<li class="section-item">
<div class="item-name">
<div class="type-signature">
Expand All @@ -47,6 +56,16 @@
Functions
</div>
<ul class="section-items item-table">
<li class="section-item">
<div class="overload-set item-name">
<div class="overload">
<div class="function-signature"><a class="function-name" href="fn.return_template.html">return_template</a></div>
</div>
</div>
<div class="description short">
<p>Returns template instantiation.</p>
</div>
</li>
<li class="section-item">
<div class="overload-set item-name">
<div class="overload">
Expand Down
7 changes: 7 additions & 0 deletions subdoc/gen_tests/templates/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ struct TemplateMethods {
static U member;
};

// Returns template parameter.
template <class U>
U template_function(U);

template <class T>
struct S {};

/// Returns template instantiation.
S<int> return_template();
24 changes: 23 additions & 1 deletion subdoc/lib/gen/markdown_to_html.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,29 @@ std::string summarize_html(std::string_view html) noexcept {

/// Removes html tags, leaving behind the text content.
std::string drop_tags(std::string_view html) noexcept {
return std::string(html); // TODO
if (html.empty()) return std::string(html);

std::ostringstream s;

bool inside_tag = false;
sus::Option<usize> text_start;
for (auto i : sus::ops::range<usize>(0u, html.size())) {
if (inside_tag) {
if (html[i] == '>') {
inside_tag = false;
text_start.insert(i + 1u);
}
} else {
if (html.substr(i).starts_with("<")) {
inside_tag = true;
if (text_start.is_some()) {
s << html.substr(*text_start, i - *text_start);
text_start = sus::none();
}
}
}
}
return sus::move(s).str();
}

} // namespace
Expand Down

0 comments on commit 2b75876

Please sign in to comment.