Skip to content

Commit 154e6c4

Browse files
committed
yes, I think it works
1 parent 75356e7 commit 154e6c4

4 files changed

Lines changed: 86 additions & 32 deletions

File tree

docs/cpp-gl/gl_traits.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ Requirements for properties that support binary coloring algorithms.
7070

7171
Requires a property type that:
7272
Satisfies c_properties.
73+
74+
7375
Has a nested `color_type`.
76+
77+
7478
Has a public `color` member of the `color_type` type.
79+
80+
7581
Supports construction and comparison with `[`gl::binary_color`](classgl_1_1binary__color.md)`.
7682

7783
### Template Parameters
@@ -490,6 +496,25 @@ Validates if a property type contains actual user-defined data.
490496

491497
Requires that the type satisfies [`gl::traits::c_properties`](gl_traits.md#gl-traits-c-properties) and is not the [`gl::empty_properties`](structgl_1_1empty__properties.md) tag.
492498

499+
500+
> [!NOTE] Highlights information that users should take into account, even when skimming.
501+
502+
503+
504+
> [!TIP] Optional information to help a user be more successful.
505+
506+
507+
508+
> [!IMPORTANT] Crucial information necessary for users to succeed.
509+
510+
511+
512+
> [!WARNING] Critical content demanding immediate user attention due to potential risks.
513+
514+
515+
516+
> [!CAUTION] Negative potential consequences of an action.
517+
493518
### Template Parameters
494519

495520
| Parameter | Description |
@@ -736,7 +761,11 @@ Requirements for properties that support arithmetic weight values.
736761

737762
Requires a property type that:
738763
Satisfies c_properties.
764+
765+
739766
Has a nested `weight_type` that satisfies c_arithmetic.
767+
768+
740769
Has a public `weight` member of the `weight_type` type.
741770

742771
### Template Parameters

include/gl/types/properties.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,21 @@ concept c_empty_properties = c_properties<T> and std::same_as<T, gl::empty_prope
260260
/// Requires that the type satisfies @ref gl::traits::c_properties and is not the @ref gl::empty_properties tag.
261261
///
262262
/// @tparam T The type to evaluate against the concept.
263+
///
264+
/// > [!NOTE]
265+
/// > Highlights information that users should take into account, even when skimming.
266+
///
267+
/// > [!TIP]
268+
/// > Optional information to help a user be more successful.
269+
///
270+
/// > [!IMPORTANT]
271+
/// > Crucial information necessary for users to succeed.
272+
///
273+
/// > [!WARNING]
274+
/// > Critical content demanding immediate user attention due to potential risks.
275+
///
276+
/// > [!CAUTION]
277+
/// > Negative potential consequences of an action.
263278
template <typename T>
264279
concept c_non_empty_properties = c_properties<T> and not c_empty_properties<T>;
265280

scripts/gen_concept_docs.py

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def xml_to_md(elem):
4040
if elem is None:
4141
return ""
4242

43+
# Ignore template parameter lists (they are handled separately for the table)
44+
if elem.tag == 'parameterlist':
45+
return ""
46+
4347
res = elem.text or ""
4448
for child in elem:
4549
if child.tag == 'ref':
@@ -49,17 +53,14 @@ def xml_to_md(elem):
4953
# 1. Known Concepts: Link exactly to their file and anchor
5054
if refid in GLOBAL_CONCEPT_LINKS:
5155
res += f"[`{ref_text}`]({GLOBAL_CONCEPT_LINKS[refid]})"
52-
53-
# 2. External/Unknown Concepts (Fallback)
56+
# 2. External/Unknown Concepts
5457
elif refid.startswith('concept'):
5558
ref_anchor = ref_text.replace("::", "-").replace("_", "-")
5659
res += f"[`{ref_text}`](#{ref_anchor})"
57-
58-
# 3. Classes, Structs, Namespaces (Fix: MkDoxy generates flat files!)
60+
# 3. Classes, Structs, Namespaces (Matches MkDoxy's flat file structure)
5961
elif refid.startswith('class') or refid.startswith('struct') or refid.startswith('namespace'):
6062
res += f"[`{ref_text}`]({refid}.md)"
61-
62-
# 4. Unknown type (Degrade gracefully to code font)
63+
# 4. Unknown
6364
else:
6465
res += f"`{ref_text}`"
6566

@@ -70,10 +71,23 @@ def xml_to_md(elem):
7071
elif child.tag == 'emphasis':
7172
res += f"*{xml_to_md(child)}*"
7273
elif child.tag == 'itemizedlist':
73-
res += "\n"
74+
res += "\n\n"
7475
for item in child.findall('listitem'):
7576
res += f"- {xml_to_md(item).strip()}\n"
76-
res += "\n"
77+
res += "\n\n"
78+
elif child.tag == 'blockquote':
79+
# Restores Markdown blockquotes (> [!NOTE]) from Doxygen XML
80+
bq_text = xml_to_md(child).strip()
81+
res += "\n\n" + "\n".join(f"> {line}" for line in bq_text.splitlines()) + "\n\n"
82+
elif child.tag == 'simplesect':
83+
# Converts native Doxygen @note, @warning into MkDocs Admonitions
84+
kind = child.get('kind', 'note').upper()
85+
sect_text = xml_to_md(child).strip()
86+
res += f"\n\n> [!{kind}]\n" + "\n".join(f"> {line}" for line in sect_text.splitlines()) + "\n\n"
87+
elif child.tag == 'para':
88+
res += xml_to_md(child).strip() + "\n\n"
89+
elif child.tag == 'title':
90+
res += f"### {xml_to_md(child).strip()}\n\n"
7791
else:
7892
res += xml_to_md(child)
7993

@@ -92,40 +106,32 @@ def parse_concept_xml(xml_path):
92106
name = root.findtext('compoundname')
93107
anchor = name.replace("::", "-").replace("_", "-")
94108

95-
# Extract descriptions using the Markdown-aware parser
96109
brief = xml_to_md(root.find('briefdescription')).strip()
97110

98-
details = ""
99111
params = []
100-
101112
detailed_desc = root.find('detaileddescription')
102113
if detailed_desc is not None:
103-
for para in detailed_desc.findall('para'):
104-
param_list = para.find('.//parameterlist[@kind="templateparam"]')
105-
if param_list is not None:
106-
for item in param_list.findall('parameteritem'):
107-
p_name = xml_to_md(item.find('.//parametername')).strip()
108-
p_desc = xml_to_md(item.find('.//parameterdescription')).strip()
109-
params.append({"name": p_name, "desc": p_desc})
110-
para.remove(param_list) # Remove so it isn't rendered twice
111-
112-
para_text = xml_to_md(para).strip()
113-
if para_text:
114-
details += para_text + "\n\n"
115-
116-
# Safely extract definition using strict get_text (NO Markdown allowed)
114+
# Extract template parameters safely to build the Markdown Table
115+
for param_list in detailed_desc.findall('.//parameterlist[@kind="templateparam"]'):
116+
for item in param_list.findall('parameteritem'):
117+
p_name = xml_to_md(item.find('.//parametername')).strip()
118+
p_desc = xml_to_md(item.find('.//parameterdescription')).strip()
119+
params.append({"name": p_name, "desc": p_desc})
120+
# Clear the XML node so it isn't rendered twice in the main details block
121+
param_list.clear()
122+
123+
# Process the entire remaining detailed description (including blockquotes)
124+
details = xml_to_md(detailed_desc).strip()
125+
126+
# Extract C++ definition (No Markdown allowed here!)
117127
constraint = get_text(root.find('initializer')).strip()
128+
constraint = re.sub(r'=\s+', '= ', constraint) # Clean Doxygen spacing
118129

119-
# Fix Doxygen's weird spacing injections (e.g. '= c_properties')
120-
constraint = re.sub(r'=\s+', '= ', constraint)
121-
122-
# Check if Doxygen already included the 'template <...>' keyword
123130
if constraint.startswith("template"):
124131
definition = constraint
125132
if not definition.endswith(";"):
126133
definition += ";"
127134
else:
128-
# Fallback for older Doxygen versions
129135
template_decl = "template <"
130136
tpl_nodes = root.findall('.//templateparamlist/param')
131137
tpl_strings = [get_text(p.find('type')).strip() for p in tpl_nodes]
@@ -136,7 +142,7 @@ def parse_concept_xml(xml_path):
136142
"name": name,
137143
"anchor": anchor,
138144
"brief": brief,
139-
"details": details.strip(),
145+
"details": details,
140146
"params": params,
141147
"definition": definition
142148
}

tests/source/gl/test_alg_coloring.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,18 @@ TEST_CASE_TEMPLATE_DEFINE("bipartite coloring tests", TraitsType, traits_type_te
8282

8383
fs::path coloring_file_path = data_path / "bicoloring_bipartite_graph_coloring.txt";
8484

85+
// Using uint8_t results in invalid value interpretation when reading from file
86+
// Solution: the data is read as uint16_t and cast to uint8_t
8587
const auto coloring_values =
8688
load_list<std::uint16_t>(sut.n_vertices(), coloring_file_path);
8789

8890
std::transform(
8991
coloring_values.begin(),
9092
coloring_values.end(),
9193
std::back_inserter(expected_coloring),
92-
[](const std::uint16_t value) { return gl::bin_color_value{value}; }
94+
[](const std::uint16_t value) {
95+
return gl::bin_color_value{static_cast<std::uint8_t>(value)};
96+
}
9397
);
9498
}
9599

0 commit comments

Comments
 (0)