Skip to content

feat: tagfiles generation for cross-referencing in doxygen format #670

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

Conversation

fpelliccioni
Copy link
Collaborator

@fpelliccioni fpelliccioni commented Sep 12, 2024

Fixes #650

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch 2 times, most recently from dd39c17 to 30d3333 Compare September 12, 2024 10:57
Copy link
Collaborator

@alandefreitas alandefreitas left a comment

Choose a reason for hiding this comment

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

The logic for the Writer looks great. I think the only issue is where it would be called from.

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch 3 times, most recently from 669e5ee to 518dfe5 Compare October 4, 2024 14:49
@alandefreitas
Copy link
Collaborator

The problem CI has been fixed. Could you rebase this?

@alandefreitas
Copy link
Collaborator

However, we will still have a problem with the USR from Krystian's commit blocking CI.

I want to start by comparing the XML in the artifacts. Do you have the result for Boost.URL multipage? That's the one we can't risk breaking because it's already in production. It has to be compatible with the existing one.

@alandefreitas alandefreitas force-pushed the feat/tagfiles-doxygen-generation branch 2 times, most recently from 5728d41 to 4ea091f Compare October 7, 2024 16:40
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 4ea091f to 10d6cca Compare October 17, 2024 11:36
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 10d6cca to 08cbc26 Compare October 17, 2024 12:10
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@alandefreitas alandefreitas force-pushed the feat/tagfiles-doxygen-generation branch from 08cbc26 to 120b717 Compare October 17, 2024 15:43
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

Copy link
Collaborator

@alandefreitas alandefreitas left a comment

Choose a reason for hiding this comment

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

It fails with

assertion failed: n <= indent_.size() on line 203 in src/lib/Gen/xml/XMLTags.cpp

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 120b717 to e469482 Compare October 19, 2024 11:46
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@alandefreitas alandefreitas force-pushed the feat/tagfiles-doxygen-generation branch from e469482 to 7b9455e Compare October 22, 2024 22:48
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@alandefreitas
Copy link
Collaborator

The implementation of the tagfile write is excellent.

CI failed after I rebased. That was a good thing because it helped me catch a bug.

So, the reason CI is failing is trivial. The TestRunner calls if(auto err = gen_->buildOneString(generatedDocs, **corpus)), which calls Generator::buildOneString, where you changed the call to buildOne to buildOne(ss, corpus, "");. We could fix CI by just adapting AdocGenerator::buildOne to not generate the tagfile when this string is empty. However, this doesn't address the deeper issue here.

The real issue causing all of that is the API design. Your new fileName parameter in Generator::buildOne is breaking the contract of this abstract class.

  1. First of all, the new parameter is documented as @param fileName The file name to use for the output., but that's not what the implementation is doing. The filename is the filename for the tagfile, which is unrelated to the filename of the output. The parameter isn't even used in the XMLGenerator. It's even more confusing because fileName is not the filename of the tagfile but the basename to which "tag.xml" will be appended to form the tagfile filename.
  2. Most importantly, the contract of Generator::buildOne is that it renders the documentation to any output stream regardless of the filename because (i) there's not even a filename for most output types and (ii) if there were a file for each stream, the stream would become redundant. For instance, tests use buildOneString, which outputs the result to a string.

This bug was already there, but CI only made it evident. It worked before rebasing because Generator::buildOneString wasn't being covered with the AdocGenerator.

Because of how Generator expects the output to be decoupled from any filename and buildOne is based on streaming only that result to the output, the Generator should have received new virtual functions to buildTagfile(std::ostream& os, Corpus const& corpus) or something instead of buildOne trying to fill this role.

If this is hard to achieve because we can't decouple the logic of buildOne and buildTagfile, a second-best would be buildOne(std::ostream& os, Corpus const& corpus, std::ostream& tagFileOs) instead of buildOne(std::ostream& os, Corpus const& corpus, std::string_view fileName) and a new overload in Generator without std::ostream& tagFileOs which would call buildOne with a noop std::ostream for the tagFileOs.

This fixes the underlying problem and the original issue with buildOneString that's breaking CI.

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 7b9455e to f04184a Compare October 29, 2024 17:32
@fpelliccioni
Copy link
Collaborator Author

The implementation of the tagfile write is excellent.

CI failed after I rebased. That was a good thing because it helped me catch a bug.

So, the reason CI is failing is trivial. The TestRunner calls if(auto err = gen_->buildOneString(generatedDocs, **corpus)), which calls Generator::buildOneString, where you changed the call to buildOne to buildOne(ss, corpus, "");. We could fix CI by just adapting AdocGenerator::buildOne to not generate the tagfile when this string is empty. However, this doesn't address the deeper issue here.

The real issue causing all of that is the API design. Your new fileName parameter in Generator::buildOne is breaking the contract of this abstract class.

  1. First of all, the new parameter is documented as @param fileName The file name to use for the output., but that's not what the implementation is doing. The filename is the filename for the tagfile, which is unrelated to the filename of the output. The parameter isn't even used in the XMLGenerator. It's even more confusing because fileName is not the filename of the tagfile but the basename to which "tag.xml" will be appended to form the tagfile filename.
  2. Most importantly, the contract of Generator::buildOne is that it renders the documentation to any output stream regardless of the filename because (i) there's not even a filename for most output types and (ii) if there were a file for each stream, the stream would become redundant. For instance, tests use buildOneString, which outputs the result to a string.

This bug was already there, but CI only made it evident. It worked before rebasing because Generator::buildOneString wasn't being covered with the AdocGenerator.

Because of how Generator expects the output to be decoupled from any filename and buildOne is based on streaming only that result to the output, the Generator should have received new virtual functions to buildTagfile(std::ostream& os, Corpus const& corpus) or something instead of buildOne trying to fill this role.

If this is hard to achieve because we can't decouple the logic of buildOne and buildTagfile, a second-best would be buildOne(std::ostream& os, Corpus const& corpus, std::ostream& tagFileOs) instead of buildOne(std::ostream& os, Corpus const& corpus, std::string_view fileName) and a new overload in Generator without std::ostream& tagFileOs which would call buildOne with a noop std::ostream for the tagFileOs.

This fixes the underlying problem and the original issue with buildOneString that's breaking CI.

This issue is addressed. I’ll let you know once CI passes so you can review, and if it’s good to go, feel free to merge.

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from f04184a to 9b74877 Compare October 29, 2024 17:57
@fpelliccioni fpelliccioni changed the title feat: tagfiles generation for cross-referencing in doxygen format [WIP] feat: tagfiles generation for cross-referencing in doxygen format Oct 29, 2024
@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch 2 times, most recently from 9fe6bec to 88251df Compare November 25, 2024 18:20
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni
Copy link
Collaborator Author

I downloaded the demo artifacts and saw no tag files in there.

@alandefreitas

You need to specify the tagfile-path option. By default, it's empty, and no tag file will be generated unless explicitly set.

Currently, tagfile-path is defined as "relativeto": "<config-dir>" in the configuration.
I'm wondering if this is the best approach or if it should require an absolute path instead.

@alandefreitas
Copy link
Collaborator

By default, it's empty

We can change that default. Or at least enable it in CI. This can't go untested. We need these file artifacts in CI.

if it should require an absolute path instead

We never require an absolute path. The tagfile is relative to the output path. Not the config path.

@fpelliccioni
Copy link
Collaborator Author

By default, it's empty

We can change that default. Or at least enable it in CI. This can't go untested. We need these file artifacts in CI.

if it should require an absolute path instead

We never require an absolute path. The tagfile is relative to the output path. Not the config path.

I didn’t see a way to make the tagfile path relative to the output path directly. I believe I’ll need to update the code handling the configuration options to support this behavior (though I’m not entirely sure yet).

I’ll go ahead and make the necessary changes, but I’ll address this in a separate PR.

@alandefreitas
Copy link
Collaborator

Whatever you put in "relativeto" will go to an OptionProperties::relativeto string in the public settings. This function is called for all arguments so you can normalize them:

https://github.com/cppalliance/mrdocs/blob/develop/src/lib/Lib/Config.cpp#L75

When the argument is a relative path, it gets the base path for normalization here:

https://github.com/cppalliance/mrdocs/blob/develop/src/lib/Lib/Config.cpp#L95

The base path can come from "relativeto" or from the default path prefix. There's no default prefix because the string is empty by default. When it comes from "relative-to", we get it with this function call:

return getBaseDir(relativeTo, dirs);

The function only considers the Reference directories for now:

if (referenceDirKey == "config-dir") {

It doesn't currently consider other options as valid prefixes. It would probably need to change to consider the PublicSettings& self.

One thing to consider is that the output path will need to be normalized before the tagfiles path. In practice, it means the output needs to come before the tagfile option in the json file. In principle, the python script could identify dependencies between options to rearrange them but I don't think it's something we need for now.

@fpelliccioni
Copy link
Collaborator Author

Whatever you put in "relativeto" will go to an OptionProperties::relativeto string in the public settings. This function is called for all arguments so you can normalize them:

https://github.com/cppalliance/mrdocs/blob/develop/src/lib/Lib/Config.cpp#L75

When the argument is a relative path, it gets the base path for normalization here:

https://github.com/cppalliance/mrdocs/blob/develop/src/lib/Lib/Config.cpp#L95

The base path can come from "relativeto" or from the default path prefix. There's no default prefix because the string is empty by default. When it comes from "relative-to", we get it with this function call:

return getBaseDir(relativeTo, dirs);

The function only considers the Reference directories for now:

if (referenceDirKey == "config-dir") {

It doesn't currently consider other options as valid prefixes. It would probably need to change to consider the PublicSettings& self.

One thing to consider is that the output path will need to be normalized before the tagfiles path. In practice, it means the output needs to come before the tagfile option in the json file. In principle, the python script could identify dependencies between options to rearrange them but I don't think it's something we need for now.

PR created #743

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 88251df to 9f160cc Compare December 2, 2024 10:35
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 9f160cc to 385e8ee Compare December 3, 2024 15:46
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 385e8ee to 678091b Compare December 3, 2024 16:08
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 678091b to 14e9579 Compare December 3, 2024 16:27
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 14e9579 to ad6d576 Compare December 3, 2024 17:12
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from ad6d576 to 96041b6 Compare December 3, 2024 18:59
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@fpelliccioni fpelliccioni force-pushed the feat/tagfiles-doxygen-generation branch from 96041b6 to ba81b70 Compare December 10, 2024 13:40
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@alandefreitas alandefreitas force-pushed the feat/tagfiles-doxygen-generation branch from ba81b70 to 02fc87c Compare December 11, 2024 14:05
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@alandefreitas alandefreitas force-pushed the feat/tagfiles-doxygen-generation branch from 02fc87c to 3ecd787 Compare December 11, 2024 15:20
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@alandefreitas alandefreitas force-pushed the feat/tagfiles-doxygen-generation branch from 3ecd787 to 84821d0 Compare December 11, 2024 18:26
@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://670.mrdocs.prtest2.cppalliance.org/index.html

@alandefreitas alandefreitas merged commit be64902 into cppalliance:develop Dec 11, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tagfiles
3 participants