================
@@ -321,6 +321,67 @@ serializeCommonAttributes(const Info &I, json::Object &Obj,
Obj["Location"] =
serializeLocation(Symbol->DefLoc.value(), RepositoryUrl);
}
+
+ if (!I.Contexts.empty()) {
+ json::Value ContextArray = json::Array();
+ auto &ContextArrayRef = *ContextArray.getAsArray();
+ ContextArrayRef.reserve(I.Contexts.size());
+
+ std::string CurrentRelativePath;
+ bool PreviousRecord = false;
+ for (const auto &Current : I.Contexts) {
+ json::Value ContextVal = Object();
+ Object &Context = *ContextVal.getAsObject();
+ serializeReference(Current, Context);
+
+ if (ContextArrayRef.empty() && I.IT == InfoType::IT_record) {
+ // If the record's immediate context is a namespace, then the
+ // "index.html" is in the same directory.
+ if (Current.DocumentationFileName == "index") {
+ PreviousRecord = false;
+ Context["RelativePath"] = "./";
+ }
+ // If the immediate context is a record, then the file is one level
+ // above
+ else {
+ PreviousRecord = true;
+ CurrentRelativePath += "../";
+ Context["RelativePath"] = CurrentRelativePath;
+ }
+ ContextArrayRef.push_back(ContextVal);
+ continue;
+ }
+
+ // If the previous Context was a record then we already went up a level,
+ // so the current namespace index is in the same directory.
+ if (PreviousRecord && (Current.DocumentationFileName == "index")) {
+ PreviousRecord = false;
+ }
+ // If the current Context is a record but the previous wasn't a record,
+ // then the namespace index is located one level above.
+ else if (Current.DocumentationFileName != "index") {
----------------
ilovepi wrote:
ditto, here and below
https://github.com/llvm/llvm-project/pull/173297
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits