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

Conversation

joshessman-llnl
Copy link
Member

@joshessman-llnl joshessman-llnl commented Feb 2, 2021

Summary

  • This PR is a refactoring/feature
  • It does the following:
    • Refactors the DocWriter interface to be more descriptive and renames it to just Writer
    • Adds functionality to the SphinxDocWriter that adds a column for the value that was provided in the input file

Currently the DocWriter interface only requires that implementers implement a void writeDocumentation(void), which isn't a particularly descriptive signature. This PR introduces documentTable(const Table&) and finalize() methods to the interface which implementers use to document a single Table and write/flush documentation, respectively.

This allows the base Inlet class to manage traversal through the Inlet tree/hierarchy (which is writer-agnostic).

This PR also extends the SphinxDocWriter to document the provided values. This is reflected in the updated Sphinx page with the sample output. Note that Inlet does not keep track of whether the provided value was just the default value (i.e., it was not provided by the user), so the generated documentation also does not make this distinction.

Copy link
Member

@kennyweiss kennyweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joshessman-llnl -- this is a nice improvment.

Are the callback functions added to the tables? (Perhaps I missed it).
Ideally, they would list their signature in addition to other metadata.

src/axom/inlet/examples/nested_structs.cpp Outdated Show resolved Hide resolved
@joshessman-llnl
Copy link
Member Author

joshessman-llnl commented Feb 3, 2021

Are the callback functions added to the tables? (Perhaps I missed it).
Ideally, they would list their signature in addition to other metadata.

Not currently - I'll tag this as an issue since I would prefer to do that as a separate PR in the interest of keeping PRs reasonably sized when possible.

std::ofstream m_outFile;
std::ostringstream m_oss;
// This is needed to preserve the traversal order of the Inlet::Tables
std::vector<std::string> m_inletTablePathNames;
std::unordered_map<std::string, TableData> m_rstTables;
std::string m_fileName;
// Used for the RST tables for fields
std::vector<std::string> m_colLabels;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Since you already depend on Sidre, you might consider using a sidre::MapCollection for this.
The data is stored in an integer-indexed array, but entries can be indexed by strings.

See: https://github.com/LLNL/axom/blob/develop/src/axom/sidre/core/MapCollection.hpp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that something like this might be useful, but the use of raw pointers as the stored item instead of objects themselves would require introducing manual memory management here (I think) since I want the data to be owned by the container.

I'll have to tweak this logic a bit anyways when I add callback function documentation, so possibly a more elegant solution will present itself.

*******************************************************************************
* \file Writer.hpp
*
* \brief This file contains the abstract base class definition of Writer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this abstraction.
I can imagine a use-case where one would want to output each top-level table in a separate file.

RELEASE-NOTES.md Outdated Show resolved Hide resolved
@joshessman-llnl
Copy link
Member Author

LGTM

@joshessman-llnl
Copy link
Member Author

LGTM

@joshessman-llnl joshessman-llnl merged commit 12aedf0 into develop Feb 16, 2021
@joshessman-llnl joshessman-llnl deleted the feature/essman/docwriter_cleanup branch February 16, 2021 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants