Skip to content

Commit

Permalink
feat: tagfiles generation for cross-referencing in doxygen format
Browse files Browse the repository at this point in the history
  • Loading branch information
fpelliccioni committed Sep 12, 2024
1 parent 5dc3884 commit 30d3333
Show file tree
Hide file tree
Showing 9 changed files with 670 additions and 1 deletion.
33 changes: 33 additions & 0 deletions include/mrdocs/Corpus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,39 @@ class MRDOCS_VISIBLE
}
}

/** Visit the members of specified Info.
This function iterates the members of the specified
Info `I`. For each member associated with a
function with the same name as the member, the
function object `f` is invoked with the member
as the first argument, followed by `args...`.
When there are more than one member function
with the same name, the function object `f` is
invoked with an @ref OverloadSet as the first
argument, followed by `args...`.
@param I The Info to traverse.
@param pred The predicate to use to determine if the member should be visited.
@param f The function to invoke with the member as the first argument, followed by `args...`.
@param args The arguments to pass to the function.
*/
template <InfoParent T, class Pred, class F, class... Args>
void
traverseIf(
T const& I, Pred&& pred, F&& f, Args&&... args) const
{
for (auto const& id : I.Members)
{
if (pred(get(id)))
{
visit(get(id), std::forward<F>(f),
std::forward<Args>(args)...);
}
}
}

/** Visit the function members of specified Info.
This function iterates the members of the specified
Expand Down
1 change: 1 addition & 0 deletions include/mrdocs/Generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class MRDOCS_VISIBLE
@li "adoc" Asciidoctor
@li "xml" XML
@li "html" HTML
@li "tagfile" Tagfile
The returned string should not include
a leading period.
Expand Down
45 changes: 45 additions & 0 deletions src/lib/Gen/tagfile/TagfileGenerator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// This is a derivative work. originally part of the LLVM Project.
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Copyright (c) 2024 Fernando Pelliccioni ([email protected])
//
// Official repository: https://github.com/cppalliance/mrdocs
//

#include "TagfileGenerator.hpp"
#include "TagfileWriter.hpp"
#include "lib/Support/Radix.hpp"
#include "lib/Support/RawOstream.hpp"
#include <mrdocs/Support/Error.hpp>
#include <mrdocs/Metadata.hpp>

namespace clang {
namespace mrdocs {
namespace tagfile {

Error
TagfileGenerator::
buildOne(
std::ostream& os,
Corpus const& corpus) const
{
namespace fs = llvm::sys::fs;
RawOstream raw_os(os);
return TagfileWriter(raw_os, corpus).build();
}

} // tagfile

//------------------------------------------------

std::unique_ptr<Generator>
makeTagfileGenerator()
{
return std::make_unique<tagfile::TagfileGenerator>();
}

} // mrdocs
} // clang
57 changes: 57 additions & 0 deletions src/lib/Gen/tagfile/TagfileGenerator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// This is a derivative work. originally part of the LLVM Project.
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Copyright (c) 2024 Fernando Pelliccioni ([email protected])
//
// Official repository: https://github.com/cppalliance/mrdocs
//

#ifndef MRDOCS_LIB_GEN_TAGFILE_TAGFILEGENERATOR_HPP
#define MRDOCS_LIB_GEN_TAGFILE_TAGFILEGENERATOR_HPP

#include <mrdocs/Platform.hpp>
#include <mrdocs/Generator.hpp>
#include <mrdocs/MetadataFwd.hpp>
#include <mrdocs/Metadata/Javadoc.hpp>
#include <optional>

namespace clang {
namespace mrdocs {
namespace tagfile {

//------------------------------------------------

struct TagfileGenerator : Generator
{
std::string_view
id() const noexcept override
{
return "tagfile";
}

std::string_view
displayName() const noexcept override
{
return "Doxygen Tagfile";
}

std::string_view
fileExtension() const noexcept override
{
return "tag.xml";
}

Error
buildOne(
std::ostream& os,
Corpus const& corpus) const override;
};

} // tagfile
} // mrdocs
} // clang

#endif
Loading

0 comments on commit 30d3333

Please sign in to comment.