Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #36 from brycelelbach/prefer-group-refs-to-namespa…
Browse files Browse the repository at this point in the history
…ce-refs

Prefer linking to entities in groups instead of entities in namespaces
  • Loading branch information
matusnovak authored Jan 12, 2021
2 parents f685df8 + d20a926 commit 4de70cf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
22 changes: 20 additions & 2 deletions src/Doxybook/Doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,27 @@ void Doxybook2::Doxygen::load(const std::string& inputDir) {
// This includes refid, brief, and list of members.
// This won't load detailed documentation or other data! (we will do that later)
const auto kindRefidMap = getIndexKinds(inputDir);

// First load all basic information from groups.
for (const auto& pair : kindRefidMap) {
if (!isKindAllowedGroup(pair.first))
continue;
try {
auto found = cache.find(pair.second);
if (found == cache.end()) {
index->children.push_back(Node::parse(cache, inputDir, pair.second, true));
auto child = index->children.back();
if (child->parent == nullptr) {
child->parent = index.get();
}
}
} catch (std::exception& e) {
WARNING("Failed to parse member {} error: {}", pair.second, e.what());
}
}
// Then load basic information from all other nodes.
for (const auto& pair : kindRefidMap) {
if (!isKindAllowedLanguage(pair.first))
if (!isKindAllowedLanguage(pair.first) || isKindAllowedGroup(pair.first))
continue;
try {
auto found = cache.find(pair.second);
Expand All @@ -81,7 +100,6 @@ void Doxybook2::Doxygen::load(const std::string& inputDir) {
WARNING("Failed to parse member {} error: {}", pair.second, e.what());
}
}

cleanup(index);

// Next, load all groups
Expand Down
34 changes: 18 additions & 16 deletions src/Doxybook/JsonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,25 @@ nlohmann::json Doxybook2::JsonConverter::getAsJson(const Node& node) const {
nlohmann::json json = convert(node);
nlohmann::json dataJson = convert(node, data);
json.insert(dataJson.begin(), dataJson.end());
if (node.getParent()->getKind() != Kind::INDEX) {
std::list<const Node*> list;
auto parent = node.getParent();
while (parent != nullptr) {
list.push_front(parent);
parent = parent->getParent();
if (parent && parent->getKind() == Kind::INDEX)
parent = nullptr;
}
nlohmann::json breadcrumbs = nlohmann::json::array();
for (const auto& ptr : list) {
breadcrumbs.push_back(convert(*ptr));
if (node.getParent() != nullptr) {
if (node.getParent()->getKind() != Kind::INDEX) {
std::list<const Node*> list;
auto parent = node.getParent();
while (parent != nullptr) {
list.push_front(parent);
parent = parent->getParent();
if (parent && parent->getKind() == Kind::INDEX)
parent = nullptr;
}
nlohmann::json breadcrumbs = nlohmann::json::array();
for (const auto& ptr : list) {
breadcrumbs.push_back(convert(*ptr));
}
json["parentBreadcrumbs"] = std::move(breadcrumbs);
json["parent"] = convert(*node.getParent());
} else {
json["parent"] = nullptr;
}
json["parentBreadcrumbs"] = std::move(breadcrumbs);
json["parent"] = convert(*node.getParent());
} else {
json["parent"] = nullptr;
}

if (node.getGroup() != nullptr) {
Expand Down

0 comments on commit 4de70cf

Please # to comment.