Skip to content

Commit

Permalink
doxygen: decltype extraction from argstr
Browse files Browse the repository at this point in the history
  • Loading branch information
MykolaGolubyev committed Mar 1, 2024
1 parent 946fb26 commit eceeda9
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add: Display [Doxygen](CPP/doxygen-setup) `decltype`
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class DoxygenMember {
private DoxygenCompound compound;
private String id;
private String name;
private String declType;
private ApiLinkedText returnType;
private DoxygenDescription description;
private String visibility;
Expand Down Expand Up @@ -97,6 +98,14 @@ public void setName(String name) {
this.name = name;
}

public String getDeclType() {
return declType;
}

public void setDeclType(String declType) {
this.declType = declType;
}

public boolean matchesArgs(String normalizedArgsToMatch) {
return normalizedParamsSignature.equals(normalizedArgsToMatch);
}
Expand Down Expand Up @@ -192,6 +201,7 @@ public Map<String, Object> toMap() {
result.put("name", name);
result.put("visibility", visibility);
result.put("kind", kind);
result.put("declType", declType);
result.put("isVirtual", isVirtual);
result.put("isFunction", isFunction());
result.put("isConst", isConst);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private void parseMember(Node memberNode) {
member.setVirtual("virtual".equals(XmlUtils.getAttributeText(memberNode, "virt")));
member.setConst("yes".equals(XmlUtils.getAttributeText(memberNode, "const")));
member.setNoExcept("yes".equals(XmlUtils.getAttributeText(memberNode, "noexcept")));
member.setDeclType(extractDeclType(XmlUtils.nextLevelNodeByName(memberNode, "argsstring").getTextContent()));

DocStructure docStructure = componentsRegistry.docStructure();
member.setReturnType(DoxygenTextWithLinksParser.parse(docStructure,
Expand Down Expand Up @@ -81,4 +82,16 @@ private void parseMember(Node memberNode) {
DoxygenDescriptionParser.parseFull(componentsRegistry, member.getParameters(), member.getName(),
XmlUtils.anyNestedNodeByName(memberNode, "detaileddescription"))));
}

/*
extracting decltype(expression) from argsstring. assumption that it is the last thing in the argstring xml node
*/
private String extractDeclType(String args) {
int idx = args.indexOf("decltype(");
if (idx == -1) {
return "";
}

return args.substring(idx).trim();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DoxygenMemberParserTest {

member.id.should == 'funcs_8h_1a9fcf12f40086d563b0227b6d39b3ade7'
member.name.should == 'my_func'
member.declType.should == 'decltype(par1)'
member.static.should == false
member.virtual.should == false
member.const.should == true
Expand Down
5 changes: 5 additions & 0 deletions znai-reactjs/src/doc-elements/doxygen/DoxygenMember.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ a .znai-doxygen-member-name {
color: var(--znai-code-keyword-color);
white-space: pre;
}

.znai-doxygen-member-decltype {
color: var(--znai-code-class-color);
white-space: pre;
}
39 changes: 39 additions & 0 deletions znai-reactjs/src/doc-elements/doxygen/DoxygenMember.demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function doxygenMemberDemo(registry: Registry) {
<DoxygenMember
compoundName="utils::nested"
name="my_func"
declType=""
isFunction={true}
isVirtual={false}
isConst={false}
Expand All @@ -73,6 +74,7 @@ export function doxygenMemberDemo(registry: Registry) {
<DoxygenMember
compoundName="utils::nested"
name="my_func"
declType=""
isFunction={true}
isVirtual={false}
isConst={false}
Expand All @@ -93,6 +95,7 @@ export function doxygenMemberDemo(registry: Registry) {
isNoExcept={false}
compoundName=""
name="my_func"
declType=""
url="#test_link"
returnType={[{ text: "MyClass", url: "#MyClass__8x" }]}
parameters={parameters}
Expand All @@ -108,6 +111,7 @@ export function doxygenMemberDemo(registry: Registry) {
isNoExcept={false}
compoundName="utils::MyClass"
name="my_func"
declType=""
url="#test_link"
returnType={[{ text: "MyClass", url: "#MyClass__8x" }]}
parameters={parameters}
Expand All @@ -123,6 +127,7 @@ export function doxygenMemberDemo(registry: Registry) {
isNoExcept={false}
compoundName="utils::MyClass"
name="var_name"
declType=""
url="#test_link"
returnType={[{ text: "MyClass", url: "#MyClass__8x" }]}
parameters={[]}
Expand All @@ -138,6 +143,7 @@ export function doxygenMemberDemo(registry: Registry) {
isNoExcept={false}
compoundName="utils::MyClass"
name="my_func"
declType=""
url="#test_link"
returnType={[{ text: "MyClass", url: "#MyClass__8x" }]}
parameters={parameters}
Expand All @@ -153,6 +159,39 @@ export function doxygenMemberDemo(registry: Registry) {
isNoExcept={true}
compoundName="utils::MyClass"
name="my_func"
declType=""
url="#test_link"
returnType={[{ text: "MyClass", url: "#MyClass__8x" }]}
parameters={parameters}
/>
));

registry.add("noexcept const", () => (
<DoxygenMember
isFunction={true}
isVirtual={false}
isConst={true}
isStatic={false}
isNoExcept={true}
compoundName="utils::MyClass"
name="my_func"
declType=""
url="#test_link"
returnType={[{ text: "MyClass", url: "#MyClass__8x" }]}
parameters={parameters}
/>
));

registry.add("decltype", () => (
<DoxygenMember
isFunction={true}
isVirtual={false}
isConst={false}
isStatic={false}
isNoExcept={true}
compoundName="utils::MyClass"
name="my_func"
declType="decltype(p1)"
url="#test_link"
returnType={[{ text: "MyClass", url: "#MyClass__8x" }]}
parameters={parameters}
Expand Down
3 changes: 3 additions & 0 deletions znai-reactjs/src/doc-elements/doxygen/DoxygenMember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import "./DoxygenMember.css";
interface Props {
compoundName: string;
name: string;
declType: string;
url?: string;
isFunction: boolean;
isStatic: boolean;
Expand All @@ -41,6 +42,7 @@ interface Props {
export function DoxygenMember({
compoundName,
name,
declType,
url,
returnType,
isFunction,
Expand Down Expand Up @@ -115,6 +117,7 @@ export function DoxygenMember({
{isFunction && <div className="znai-doxygen-member-params-separator">)</div>}
{isConst && <div className="znai-doxygen-member-classifier"> const</div>}
{isNoExcept && <div className="znai-doxygen-member-classifier"> noexcept</div>}
{declType && <div className="znai-doxygen-member-decltype"> -&gt; {declType}</div>}
</div>
)}
</div>
Expand Down

0 comments on commit eceeda9

Please sign in to comment.