Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Inlet's DocWriter interface, add support for documenting provided values #446

Merged
merged 10 commits into from
Feb 16, 2021
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
- Inlet: Added support for deeply nested containers of structs
- Inlet: Added support for `void` and strings in Lua-defined functions
- Inlet: Added `get<std::vector<T>>` for retrieving arrays without index information
- Inlet: SphinxDocWriter can now output the values provided in an input file
joshessman-llnl marked this conversation as resolved.
Show resolved Hide resolved

### Changed
- The Sidre Datastore no longer rewires Conduit's error handlers to SLIC by default.
Expand Down
6 changes: 3 additions & 3 deletions src/axom/inlet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ set(inlet_headers
VariantKey.hpp
Verifiable.hpp
VerifiableScalar.hpp
DocWriter.hpp
SphinxDocWriter.hpp
Writer.hpp
SphinxWriter.hpp
ConduitReader.hpp
YAMLReader.hpp
JSONReader.hpp
Expand All @@ -40,7 +40,7 @@ set(inlet_sources
Table.cpp
Proxy.cpp
VariantKey.cpp
SphinxDocWriter.cpp
SphinxWriter.cpp
ConduitReader.cpp
inlet_utils.cpp )

Expand Down
59 changes: 0 additions & 59 deletions src/axom/inlet/DocWriter.hpp

This file was deleted.

30 changes: 27 additions & 3 deletions src/axom/inlet/Inlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,40 @@ VerifiableScalar& Inlet::addString(const std::string& name,
return m_globalTable.addString(name, description);
}

void Inlet::registerDocWriter(std::unique_ptr<DocWriter> writer)
void Inlet::registerWriter(std::unique_ptr<Writer> writer)
{
m_docWriter = std::move(writer);
m_writer = std::move(writer);
}

namespace detail
{
/*!
*******************************************************************************
* \brief Recursive helper function for traversing an Inlet tree for documentation
* generation purposes
*
* \param [inout] writer The Writer to use for documentation
* \param [in] table The current table to write
*******************************************************************************
*/
void writerHelper(Writer& writer, const Table& table)
{
// Use a pre-order traversal for readability
writer.documentTable(table);
for(const auto& sub_table_entry : table.getChildTables())
{
writerHelper(writer, *sub_table_entry.second);
}
}

} // end namespace detail

void Inlet::writeDoc()
{
if(m_docEnabled)
{
m_docWriter->writeDocumentation();
detail::writerHelper(*m_writer, m_globalTable);
m_writer->finalize();
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/axom/inlet/Inlet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "axom/sidre.hpp"

#include "axom/inlet/DocWriter.hpp"
#include "axom/inlet/Writer.hpp"

namespace axom
{
Expand Down Expand Up @@ -260,22 +260,22 @@ class Inlet

/*!
*****************************************************************************
* \brief Sets the associated DocWriter for the Inlet instance.
* \brief Sets the associated Writer for the Inlet instance.
*
* Sets the associated DocWriter. If the DocWriter is already set, it will be
* Sets the associated Writer. If the Writer is already set, it will be
* replaced by the one that was most recently set.
*
* \param [in] writer An owning pointer to a DocWriter object
* \param [in] writer An owning pointer to a Writer object
*
*****************************************************************************
*/
void registerDocWriter(std::unique_ptr<DocWriter> writer);
void registerWriter(std::unique_ptr<Writer> writer);

/*!
*****************************************************************************
* \brief Writes input file documentation.
*
* This writes the input file's documentation through the registered DocWriter.
* This writes the input file's documentation through the registered Writer.
*
*****************************************************************************
*/
Expand Down Expand Up @@ -599,7 +599,7 @@ class Inlet
std::unique_ptr<Reader> m_reader;
axom::sidre::Group* m_sidreRootGroup = nullptr;
Table m_globalTable;
std::unique_ptr<DocWriter> m_docWriter;
std::unique_ptr<Writer> m_writer;
bool m_docEnabled;
};

Expand Down
Loading