-
Notifications
You must be signed in to change notification settings - Fork 94
Experimental documentation generation tool #253
Experimental documentation generation tool #253
Conversation
Adding @tcNickolas and @KittyYeungQ for reference documentation impact, @anpaz-msft for build pipeline impact. If you have any time to offer feedback on the early prototype / experiment and the broader approach, I'd really appreciate it. Thank you! |
) | ||
); | ||
|
||
internal static IAttributeBuilder<T> WithDocumentationAttributesFromDictionary<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you might want to use the tools in this PR: microsoft/qsharp-compiler#463
Let me know what attribute related things are missing, and we can see if it makes sense to add it to that static class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll take a look at that, then. One thing I ran into was that a lot of the documentation attributes take a similar form on UDTs and callables, but even though QsCallable and QsCustomType both have an AddAttribute
method, there's no common interface that allows calling AddAttribute
on both. The AttributeBuilder
class here was a hack around that to reduce code duplication.
this.Namespaces = new ProcessDocComments.NamespaceTransformation(this, outputPath); | ||
} | ||
|
||
public QsCompilation OnCompilation(QsCompilation compilation) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply (inherited from the base class) would do that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to OnCompilation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that imply that this method can be safely deleted?
|
||
private static QsCallable AddSummaryAttribute(QsCallable callable, string summary) => | ||
callable.AddAttribute( | ||
new QsDeclarationAttribute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the tools in the PR I mentioned in another comment.
) | ||
); | ||
|
||
private async Task MaybeWriteOutput(QsCustomType type, DocComment docComment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put these writers etc into a separate file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I agree; this was convenient when quickly prototyping, but is not the most maintainable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason to put this on the runtime repo rather than the compiler repo? I believe you could just have a reference to the source code version of the compiler to build the rewrite step, couldn't you?
Thanks for your feedback, @bettinaheim!
My thinking was that this is similar in principle to how the C# generation app works, and thus to put it there, but I'm happy to move this to the compiler instead if that makes more sense. |
I think it makes sense on the compiler repo, as Bettina suggested. Could you provide more information about usage? If I understand correctly these are Q# attributes that get added to the code directly and that would replace the current markdown docs, is that correct, are you planning to replace comments with attributes, or are these attributes go inside the comments? Also, will these changes be backwards compatible? Switching all the documentation will be a huge PITA. |
Thanks for your comments, @anpaz-msft! Please see responses inline below.
Sounds good, I'll move it there then and close this PR.
The new attributes are added automatically by the IRewriteStep in this PR, such that no change to Markdown documentation comments is required.
Agreed, hence this PR doesn't target changing that workflow at all, but makes the result of parsing those comments more widely available to other parts of the Quantum Development Kit (e.g.: IQ#) via attributes.
So far the only backwards-incompatible change posed is to finally fix the casing convention for API reference UIDs to not require all-lowercase. |
Moved logic to compiler repo, closing this PR in favor of new approach. |
This PR opens for early feedback a possible path towards solving microsoft/qsharp-compiler#277, namely outputting documentation Markdown directly rather than as YAML. This PR packages that effort as an IRewriteStep that can be controlled by the
IRewriteStep.AssemblyConstants
property, and that can be included as anIsQscReference
. The step also attaches documentation information as attributes that can be used by other parts of the Quantum Development Kit, such as IQ#.Improvements over the existing approach:
Remaining work:
@Deprecated()
; this is currently supported by the non-experimental documentation generator.@Attribute()
, making it hard to learn how attributes should be used./// # See Also
blocks.