================
@@ -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 {
----------------
ilovepi wrote:

Can we keep the `} else {` bit on the same line? It took me a second to realize 
this wasn't a second condition.  The comment can go inside the block, or could 
be folded into the comment above:

 ```
... directory. Otherwise, the immediate context is a record, and the file is 
one level above.
```

https://github.com/llvm/llvm-project/pull/173297
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to