Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7a01a01
Remove use of FnMutRef in slice splitting
danakj Sep 9, 2023
c44fb02
Lots of docs improvements for numerics and into
danakj Sep 9, 2023
9833501
codify static_cast in comment
danakj Sep 9, 2023
a588a97
Call static ctor methods "type-deduction constructor funtions" in docs
danakj Sep 9, 2023
a12c38a
Replace use of FnOnceRef with FnOnce in Peekable
danakj Sep 9, 2023
a0244c3
Link to fn concepts from the call functions
danakj Sep 9, 2023
3e82b76
Links on fn return type concepts
danakj Sep 9, 2023
a6a6c56
Add DynConcept, Dyn, and make DynError satisfy DynConcept
danakj Sep 10, 2023
6ee2017
Add DynFn type-erased virtual classes
danakj Sep 10, 2023
42eafa7
When building the storage reference, work with rvalue correctly
danakj Sep 10, 2023
296818d
Support getting an lvalue ref from Dyn when it's an lvalue.
danakj Sep 10, 2023
4a44900
Avoid needing to be able to construct in order to look for NeverValue
danakj Sep 10, 2023
47c7184
Avoid conflicting comments on constructors
danakj Sep 10, 2023
46a9f37
Remove use of FnOnceRef in subdoc
danakj Sep 10, 2023
4b6d36c
Remove use of FnMutRef and FnMutBox in subdoc
danakj Sep 10, 2023
7a9d7c3
Remove FnBoxMut from RepeatWith and make it constexpr
danakj Sep 10, 2023
b9fa113
Implement iterator max_by_key and min_by_key more efficiently
danakj Sep 10, 2023
39ab44e
Box<DynFn> now is a Fn itself and add tons of docs for type-erasure a…
danakj Sep 10, 2023
2ee325d
Add some missing template keywords
danakj Sep 10, 2023
b4c2d8f
Fix from overload tags to fix links
danakj Sep 10, 2023
3ee7b6f
Improve Box<DynFn> docs
danakj Sep 10, 2023
6de324d
Fix type in codelink
danakj Sep 10, 2023
dd02c0e
Make all overloads with the same parameters but different method qual…
danakj Sep 10, 2023
b9c3d3a
Change FnMut concept to use `requires (F&)` not `requires (F)`
danakj Sep 10, 2023
e4833c9
Add docs for the boxed namespace
danakj Sep 10, 2023
fcbb850
Remove FnMutBox from OnceWith and make it constexpr
danakj Sep 10, 2023
88bbcf1
Remove FnMutBox from Successors and make it constexpr
danakj Sep 10, 2023
54b831a
Remove use of FnBox in subdoc RunOptions
danakj Sep 10, 2023
72968c4
Remove the FnRef and FnBox types
danakj Sep 11, 2023
5c47bd0
Provide a way to construct a Box<T> for non-Move T
danakj Sep 11, 2023
6cc13f1
Syntax-highlight colourize comments in pre blocks
danakj Sep 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ footguns, crashes, bugs, and UB.
* But don't follow the IWYU rules _inside_ the library. We include the minimal internal
headers internally to reduce the amount of textual parsing needed to satisfy
including one public header.
1. All types in requires clauses should be references or pointers.
* For mutable access always write it as `requires(T& t)` instead of
`requires (T t)`, as the latter will not match pure virtual types in
clang-16.
* Similarly, for const usage, write `requires (const T& t)` instead of
`requires (const T t)`.
82 changes: 82 additions & 0 deletions subdoc/gen_tests/markdown/Syntax.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>

<head>
<meta name="generator" content="subdoc"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<meta property="og:type" content="website"></meta>
<meta property="og:site_name" content="PROJECT NAME"></meta>
<title>Syntax - PROJECT NAME</title>
<meta property="og:title" content="Syntax - PROJECT NAME"></meta>
<meta name="description" content="A code block with syntax highlighting."></meta>
<meta property="og:description" content="A code block with syntax highlighting."></meta>
<link rel="stylesheet" href="../subdoc-test-style.css">
<link rel="icon" type="image/svg+xml" href="../icon.svg">
<link rel="alternate icon" type="image/png" href="../icon.png">
<meta property="og:image" content="../icon.svg"></meta>
</head>

<body>
<nav class="topbar">
<button class="sidebar-menu-button" onclick="let e = document.getElementsByClassName('sidebar')[0];e.classList.toggle('shown');">
</button>
<a class="topbar-logo-link" href="index.html"><div class="topbar-logo-border">
<img class="topbar-logo" src="PROJECT LOGO.png"></img>
</div></a>
<span class="topbar-text-area">
<span class="topbar-title">
<a href="#">Syntax</a>
</span>
</span>
</nav>
<nav class="sidebar">
<a class="sidebar-logo-link" href="index.html"><div class="sidebar-logo-border">
<img class="sidebar-logo" src="PROJECT LOGO.png"></img>
</div></a>
<div class="sidebar-pretitle sidebar-text">
struct
</div>
<div class="sidebar-title sidebar-text">
<a href="#">Syntax</a>
</div>
<div class="sidebar-subtitle sidebar-text">
</div>
<div class="sidebar-links sidebar-text">
<ul>
</ul>
</div>
</nav>
<main>
<div class="type record struct">
<div class="section overview">
<div class="section-header">
<span>
Struct
</span>
<a class="project-name" href="index.html">PROJECT NAME</a>
<span class="namespace-dots">::</span>
<a class="type-name" href="#">Syntax</a>
</div>
<div class="type-signature">
<span class="struct">
struct
</span>
<span class="type-name">
Syntax
</span>
<div class="record-body">
{ ... };
</div>
</div>
<div class="description long">
<p>A code block with syntax highlighting.</p>
<pre><code>A comment; <span class="comment">// At the end of the line.</span>
<span class="comment">// At the start of the line.</span>
<span class="comment">// And after some whitespace.</span>
</code></pre>

</div>
</div>
</div>
</main>
</body>
13 changes: 13 additions & 0 deletions subdoc/gen_tests/markdown/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<li>
<a class="sidebar-item" href="S.html">S</a>
</li>
<li>
<a class="sidebar-item" href="Syntax.html">Syntax</a>
</li>
</ul>
</div>
</nav>
Expand Down Expand Up @@ -91,6 +94,16 @@
<p>The <code>summary</code> has <b>html tags</b> in it.</p>
</div>
</li>
<li class="section-item">
<div class="item-name">
<div class="type-signature">
<a class="type-name" href="Syntax.html">Syntax</a>
</div>
</div>
<div class="description short">
<p>A code block with syntax highlighting.</p>
</div>
</li>
</ul>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions subdoc/gen_tests/markdown/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ struct S {};
/// newlines in
/// it.
struct N {};

/// A code block with syntax highlighting.
/// ```
/// A comment; // At the end of the line.
/// // At the start of the line.
/// // And after some whitespace.
/// ```
struct Syntax {};
28 changes: 28 additions & 0 deletions subdoc/gen_tests/struct-complex/S.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
<li>
<a class="sidebar-item" href="S.html#method.void_method">void_method</a>
</li>
<li>
<a class="sidebar-header" href="#operators">Operators</a>
</li>
<li>
<a class="sidebar-item" href="S.html#method.operator()">operator()</a>
</li>
<li>
<a class="sidebar-header" href="#data-members">Data Members</a>
</li>
Expand Down Expand Up @@ -190,6 +196,28 @@
</div>
</div>
</div>
<div class="section methods nonstatic">
<div class="section-header">
<a name="operators" href="#operators">Operators</a>
</div>
<div class="section-items">
<div class="overload-set item-name">
<div class="overload">
<div class="function-signature"><a name="method.operator()"></a><span class="function-auto">auto</span> <a class="function-name" href="S.html#method.operator()">operator()</a>() const& -&gt; int</div>
</div>
<div class="overload">
<div class="function-signature"><a name="method.operator()"></a><span class="function-auto">auto</span> <a class="function-name" href="S.html#method.operator()">operator()</a>() & -&gt; bool</div>
</div>
<div class="overload">
<div class="function-signature"><a name="method.operator()"></a><span class="function-auto">auto</span> <a class="function-name" href="S.html#method.operator()">operator()</a>() && -&gt; float</div>
</div>
</div>
<div class="description long">
<p>Call operator with two overloads.</p>

</div>
</div>
</div>
<div class="section fields nonstatic">
<div class="section-header">
<a name="data-members" href="#data-members">Data Members</a>
Expand Down
15 changes: 10 additions & 5 deletions subdoc/gen_tests/struct-complex/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ struct OtherType {};
/// Comment headline S
struct S {
/// Comment headline void_method
void void_method() const& {}
void void_method() const&;
/// Comment headline static_type_method
static OtherType static_type_method() {}
static OtherType static_type_method();
/// Comment headline type_method
OtherType type_method() {}
OtherType type_method();
/// Comment headline static_bool_method
static bool static_bool_method() {}
static bool static_bool_method();

// Overload should be grouped with the other int_method().
void int_method() volatile {}
void int_method() volatile;

/// Comment headline type_field
const OtherType type_field;
Expand All @@ -25,4 +25,9 @@ struct S {
bool bool_field;
/// Comment headline static_bool_member
static bool static_bool_member;

/// Call operator with two overloads.
int operator()() const&;
bool operator()() &;
float operator()() &&;
};
3 changes: 3 additions & 0 deletions subdoc/gen_tests/subdoc-test-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ main {
color:rgb(230, 230, 230);
overflow-x: auto;
}
pre > code span.comment {
color: #3ff9bd;
}

.section-header {
font-size: 125%;
Expand Down
95 changes: 48 additions & 47 deletions subdoc/lib/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

#include "subdoc/lib/doc_attributes.h"
#include "subdoc/lib/friendly_names.h"
#include "subdoc/lib/linked_type.h"
#include "subdoc/lib/method_qualifier.h"
#include "subdoc/lib/parse_comment.h"
#include "subdoc/lib/path.h"
#include "subdoc/lib/record_type.h"
#include "subdoc/lib/requires.h"
#include "subdoc/lib/type.h"
#include "subdoc/lib/linked_type.h"
#include "subdoc/lib/unique_symbol.h"
#include "subdoc/llvm.h"
#include "sus/assertions/check.h"
Expand Down Expand Up @@ -226,7 +226,7 @@ struct FunctionElement : public CommentElement {
return sus::none();
}

void for_each_comment(sus::fn::FnMutRef<void(Comment&)> fn) { fn(comment); }
void for_each_comment(sus::fn::FnMut<void(Comment&)> auto fn) { fn(comment); }
};

struct ConceptElement : public CommentElement {
Expand Down Expand Up @@ -262,7 +262,7 @@ struct ConceptElement : public CommentElement {
return sus::none();
}

void for_each_comment(sus::fn::FnMutRef<void(Comment&)> fn) { fn(comment); }
void for_each_comment(sus::fn::FnMut<void(Comment&)> auto fn) { fn(comment); }
};

struct FieldElement : public CommentElement {
Expand Down Expand Up @@ -310,7 +310,7 @@ struct FieldElement : public CommentElement {
return sus::none();
}

void for_each_comment(sus::fn::FnMutRef<void(Comment&)> fn) { fn(comment); }
void for_each_comment(sus::fn::FnMut<void(Comment&)> auto fn) { fn(comment); }
};

struct ConceptId {
Expand Down Expand Up @@ -552,7 +552,7 @@ struct RecordElement : public TypeElement {
return out;
}

void for_each_comment(sus::fn::FnMutRef<void(Comment&)> fn) {
void for_each_comment(sus::fn::FnMut<void(Comment&)> auto fn) {
fn(comment);
for (auto& [k, e] : records) e.for_each_comment(fn);
for (auto& [k, e] : fields) e.for_each_comment(fn);
Expand Down Expand Up @@ -736,7 +736,7 @@ struct NamespaceElement : public CommentElement {
return out;
}

void for_each_comment(sus::fn::FnMutRef<void(Comment&)> fn) {
void for_each_comment(sus::fn::FnMut<void(Comment&)> auto fn) {
fn(comment);
for (auto& [k, e] : concepts) e.for_each_comment(fn);
for (auto& [k, e] : namespaces) e.for_each_comment(fn);
Expand Down Expand Up @@ -777,13 +777,11 @@ struct Database {
sus::Vec<Comment*> to_resolve;
{
sus::Vec<Comment*>* to_resolve_ptr = &to_resolve;
sus::fn::FnMutBox<void(Comment&)> fn = sus_bind_mut(
sus_store(sus_unsafe_pointer(to_resolve_ptr)), [&](Comment& c) {
if (c.attrs.inherit.is_some()) {
to_resolve_ptr->push(&c);
}
});
global.for_each_comment(fn);
global.for_each_comment([&](Comment& c) {
if (c.attrs.inherit.is_some()) {
to_resolve_ptr->push(&c);
}
});
}

while (!to_resolve.is_empty()) {
Expand Down Expand Up @@ -931,41 +929,44 @@ struct Database {
sus::Vec<sus::Option<TypeRef>> collect_type_element_refs(
const Type& type) const noexcept {
sus::Vec<sus::Option<TypeRef>> vec;
type_walk_types(type, [&](TypeToStringQuery q) {
const NamespaceElement* ns_cursor = &global;
for (const std::string& name : q.namespace_path) {
auto it = ns_cursor->namespaces.find(NamespaceId(name));
if (it == ns_cursor->namespaces.end()) {
vec.push(sus::none());
return;
}
ns_cursor = &it->second;
}
if (q.record_path.is_empty()) {
vec.push(ns_cursor->get_local_type_element_ref_by_name(q.name));
return;
}
type_walk_types(
type,
sus::dyn<sus::fn::DynFnMut<void(TypeToStringQuery)>>(
[&](TypeToStringQuery q) {
const NamespaceElement* ns_cursor = &global;
for (const std::string& name : q.namespace_path) {
auto it = ns_cursor->namespaces.find(NamespaceId(name));
if (it == ns_cursor->namespaces.end()) {
vec.push(sus::none());
return;
}
ns_cursor = &it->second;
}
if (q.record_path.is_empty()) {
vec.push(ns_cursor->get_local_type_element_ref_by_name(q.name));
return;
}

const RecordElement* rec_cursor = nullptr;
for (const auto& [i, name] : q.record_path.iter().enumerate()) {
if (i == 0u) {
auto it = ns_cursor->records.find(RecordId(name));
if (it == ns_cursor->records.end()) {
vec.push(sus::none());
return;
}
rec_cursor = &it->second;
} else {
auto it = rec_cursor->records.find(RecordId(name));
if (it == rec_cursor->records.end()) {
vec.push(sus::none());
return;
}
rec_cursor = &it->second;
}
}
vec.push(rec_cursor->get_local_type_element_ref_by_name(q.name));
});
const RecordElement* rec_cursor = nullptr;
for (const auto& [i, name] : q.record_path.iter().enumerate()) {
if (i == 0u) {
auto it = ns_cursor->records.find(RecordId(name));
if (it == ns_cursor->records.end()) {
vec.push(sus::none());
return;
}
rec_cursor = &it->second;
} else {
auto it = rec_cursor->records.find(RecordId(name));
if (it == rec_cursor->records.end()) {
vec.push(sus::none());
return;
}
rec_cursor = &it->second;
}
}
vec.push(rec_cursor->get_local_type_element_ref_by_name(q.name));
}));
return vec;
}

Expand Down
9 changes: 6 additions & 3 deletions subdoc/lib/gen/generate_function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ void generate_function_params(HtmlWriter::OpenDiv& div,
if (p.parameter_name.empty()) {
generate_type(div, p.type, sus::none());
} else {
generate_type(div, p.type, sus::some([&](HtmlWriter::OpenDiv& div) {
div.write_text(p.parameter_name);
}));
generate_type(
div, p.type,
sus::some(sus::dyn<sus::fn::DynFnMut<void(HtmlWriter::OpenDiv&)>>(
[&](HtmlWriter::OpenDiv& div) {
div.write_text(p.parameter_name);
})));
}

if (p.default_value.is_some()) {
Expand Down
Loading