Bug 178386 - Editor support for documentation tool comments
Summary: Editor support for documentation tool comments
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 4.0   Edit
Hardware: All All
: P3 enhancement with 6 votes (vote)
Target Milestone: 5.0   Edit
Assignee: Andrew Ferguson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 23545 24686 (view as bug list)
Depends on: 208881
Blocks:
  Show dependency tree
 
Reported: 2007-03-20 15:13 EDT by Emilio Monti CLA
Modified: 2014-01-29 18:25 EST (History)
10 users (show)

See Also:


Attachments
patch for discussion (310.17 KB, patch)
2007-11-12 10:01 EST, Andrew Ferguson CLA
no flags Details | Diff
catches up with HEAD (370.54 KB, patch)
2008-01-23 10:46 EST, Andrew Ferguson CLA
no flags Details | Diff
patch applied to HEAD (442.28 KB, patch)
2008-02-09 07:26 EST, Andrew Ferguson CLA
cdtdoug: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Emilio Monti CLA 2007-03-20 15:13:37 EDT
Doxygen is the de-facto standard for C/C++ documentation generation, there should be a "generate element comment" command sensible to the user selection (function prototype, class, define, etc).

KDevelop (for C and C++ with Doxygen) and JDT (for Java with JavaDoc) already have this feature.
Comment 1 Chris Recoskie CLA 2007-09-11 13:47:25 EDT
Help wanted.  No one is currently looking at this.
Comment 2 Andrew Ferguson CLA 2007-11-01 12:43:51 EDT
hi,
 
 We have an internal plug-in for this that I'm looking to clean up and submit for CDT 5.0 if possible. I spoke with Anton at the fall summit about some potential architectural issues involved which I'd like to ask advice on in a bit more detail:

The overall idea is pretty simple - allow people to plug-in different SourceViewer tools (e.g. scanners, auto-edit-strategies etc..) for 'documentation comments'. Documentation comments would be those singleline or multiline comments which are determined by the plug-in to be processable by the tool in question.

There is a complication if you try to allow multiple plug-ins to be active at the same time - e.g. allow projectA to be associated with doxygen, and allow projectB to be associated with cppdoc.

The two approaches to resolving this I've looked at each have their own problems.

=== Approach 1: Retain the current ICPartition types, and have the plug-in's examine the multi-line or single-line partitions when they are invoked in order to alter their behaviour as appropriate.

This works fine but is working around some of the editor architecture.

=== Approach 2 as suggested by Anton: Define two new partition types for doc_multiline and doc_singleline and allow plug-ins to hook into FastCPartitionScanner to intercept any singleline or multiline partitions.

The issue here is we need to change the partitioner based on the associated documentation tool, and that the mechanism for doing this (IDocumentSetupParticipant) does not provide the path to the document being setup, I guess that as in general it may not have one. For documents that are in the workspace, the relative path would enable configuring the fast partitioner to recognize different documentation comments depending on the documentation tool associated with the containing project.

I've experimented with introducing updatable state to the FastCPartitionScanner, and configuring it at CEditor.doSetInput time. This does the trick but I've not yet understood if this is legitimate with respect to other document clients. If not I'd intend to look at writing an IDocumentSetupParticipantExtension that document setup participants could optionally implement to recieve this extra information and seeing how its received by the platform team.
Comment 3 Anton Leherbauer CLA 2007-11-05 09:29:36 EST
(In reply to comment #2)
> === Approach 1: Retain the current ICPartition types, and have the plug-in's
> examine the multi-line or single-line partitions when they are invoked in 
> order to alter their behaviour as appropriate.
>
> This works fine but is working around some of the editor architecture.

Could you give me a hint where this is working around the editor architecture? We have probably already talked about it, but I just can't remember ;-)

> I've experimented with introducing updatable state to the
> FastCPartitionScanner, and configuring it at CEditor.doSetInput time. This does
> the trick but I've not yet understood if this is legitimate with respect to
> other document clients. If not I'd intend to look at writing an
> IDocumentSetupParticipantExtension that document setup participants could
> optionally implement to recieve this extra information and seeing how its
> received by the platform team.

Having IDocumentSetupParticipantExtension in the platform is the preferred way if we follow approach 2. 
Although we are not necessarily bound to the IDocumentSetupParticipant mechanism, clients creating and using a document directly through the IFileBuffer infrastructure would not get the project specific partitioning in that case.
Comment 4 Andrew Ferguson CLA 2007-11-05 12:51:02 EST
(In reply to comment #3)
> Could you give me a hint where this is working around the editor architecture?
> We have probably already talked about it, but I just can't remember ;-)

its that when you have a single partition type for e.g. multiline comments, then each tool (scanner, autoedit etc.) must include code for switching between plain behaviours and doc-style comment behaviours.

For example, the original prototype documentation-comment scanner maintained internal state (switched on calls to setRange) for determining the default token type, and also for referring to from individual rules that might be doc-style comment specific. It was also needed to have a slightly-customized damage-repairer in order to correctly handle changes within the single-typed partition that would change its entire presentation (e.g. /* -> /** or /*! -> /*).

There were similar checks for swapping behaviours in other tools.

> Having IDocumentSetupParticipantExtension in the platform is the preferred way
> if we follow approach 2.
> Although we are not necessarily bound to the IDocumentSetupParticipant
> mechanism, clients creating and using a document directly through the
> IFileBuffer infrastructure would not get the project specific partitioning in
> that case.

ok, thanks. Is it correct to say there aren't any clients that take this route in CDT at the moment? Maybe having CTextTools methods related to this take an additional parameter for the documentation-comment-family that could be omitted/null would be the way to go (?).
Comment 5 Anton Leherbauer CLA 2007-11-06 05:50:33 EST
(In reply to comment #4)
> (In reply to comment #3)
> > Could you give me a hint where this is working around the editor architecture?
> > We have probably already talked about it, but I just can't remember ;-)
> its that when you have a single partition type for e.g. multiline comments,
> then each tool (scanner, autoedit etc.) must include code for switching between
> plain behaviours and doc-style comment behaviours.
> For example, the original prototype documentation-comment scanner maintained
> internal state (switched on calls to setRange) for determining the default
> token type, and also for referring to from individual rules that might be
> doc-style comment specific. It was also needed to have a slightly-customized
> damage-repairer in order to correctly handle changes within the single-typed
> partition that would change its entire presentation (e.g. /* -> /** or /*! ->
> /*).
> There were similar checks for swapping behaviours in other tools.

Thanks, I remember now.

> > Having IDocumentSetupParticipantExtension in the platform is the preferred way
> > if we follow approach 2.
> > Although we are not necessarily bound to the IDocumentSetupParticipant
> > mechanism, clients creating and using a document directly through the
> > IFileBuffer infrastructure would not get the project specific partitioning in
> > that case.
> ok, thanks. Is it correct to say there aren't any clients that take this route
> in CDT at the moment? 

CSourceHover is such a client, but that can be handled.

> Maybe having CTextTools methods related to this take an
> additional parameter for the documentation-comment-family that could be
> omitted/null would be the way to go (?).

Yes, I think that would be the way to go.

BTW, do you intend to enhance the syntax coloring preference page with doc-specific highlightings, too?
Comment 6 Andrew Ferguson CLA 2007-11-06 08:49:32 EST
> BTW, do you intend to enhance the syntax coloring preference page with
> doc-specific highlightings, too?

I'm unsure about this at the moment, it would certainly be later in the plan if so.

I've raised 208881 on platform-text to start discussion about the IDocumentSetupParticipantExtension.

Comment 7 Andrew Ferguson CLA 2007-11-06 08:52:46 EST
*** Bug 23545 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Ferguson CLA 2007-11-06 09:00:15 EST
*** Bug 24686 has been marked as a duplicate of this bug. ***
Comment 9 Andrew Ferguson CLA 2007-11-12 10:01:52 EST
Created attachment 82661 [details]
patch for discussion

hi,

The attached patch is a work-in-progress based upon approach (2) from above. It includes the potential patch for platform-text.

There is early support for doxygen, and toy support for doc++ (just to show an alternative). These both live in the ui plug-in at the moment for convenience.

There is still work to do in
 * adding further tests
 * setting of documentation comment owner property and preference page UI needs tidying up, and possibly moving to a more appropriate location
 * only one proposal computer is allowed via the IDocViewerConfiguration, I'm wondering if it really makes sense to attach them here, maybe its best to use the existing completion proposal computer extension point and allow an optional specification of documentation comment owner ID

I thought its worth specifying some items not in the scope of this bugzilla:
 * documentation comment validation and problem marker generation
 * smarter tag content-assist (e.g. @see could consult the index for proposals as JDT does). I don't think the patch precludes this - it just doesn't help here

Any feedback would be very appreciated, the patch is getting quite large so if we had an agreement on the approach I could split it into smaller parts. 

thanks,
Andrew
Comment 10 Anton Leherbauer CLA 2007-11-19 09:48:14 EST
(In reply to comment #9)

Andrew, sorry for the late reply. I was sick last week.
I just browsed through the patch and it looks very good to me. 
Comment 11 Andrew Ferguson CLA 2007-12-03 06:17:25 EST
thanks very much - I've also been out of office, but hope to pick this up again as soon as possible.
Comment 12 Andrew Ferguson CLA 2008-01-23 10:46:49 EST
Created attachment 87661 [details]
catches up with HEAD
Comment 13 Andrew Ferguson CLA 2008-01-29 09:20:02 EST
Doug, Anton, could I ask what you'd think about having Doxygen support as part of the UI plug-in?

Doug, a bit of background is that this patch adds a framework for pluggable documentation support, and an abstract 'generic' support that should form a basis for different tool plug-ins (e.g. most tools use @tags). The Doxygen support would be the only choosable plug-in if it were to go into the UI.

Comment 14 Doug Schaefer CLA 2008-01-29 10:31:36 EST
We've had numerous requests for doxygen support over the years so anything we can do in that area  would be very welcome. No one's mentioned other documentation tools so I have no problem giving doxygen most of the focus. But having an open architecture to plug-in others would open the door.
Comment 15 Anton Leherbauer CLA 2008-01-30 02:50:35 EST
(In reply to comment #13)
> Doug, Anton, could I ask what you'd think about having Doxygen support as part
> of the UI plug-in?

+1 for Doxygen. It seems to be the most popular documentation tool.
Comment 16 Andrew Ferguson CLA 2008-02-09 07:26:30 EST
Created attachment 89334 [details]
patch applied to HEAD

thanks, I've applied the above patch to HEAD (It requires the new M5 build to compile)
Comment 17 Andrew Ferguson CLA 2008-02-09 07:27:14 EST
marking as FIXED
Comment 18 Doug Schaefer CLA 2008-05-25 23:35:07 EDT
uh, did this get put through an IP review?
Comment 19 Andrew Ferguson CLA 2008-05-27 05:35:16 EDT
(In reply to comment #18)
> uh, did this get put through an IP review?

I wrote all the code (other than some utilities cloned from JDT) while having committer status. I thought/think this means it doesn't differ from any other large patches I've committed in the past?
Comment 20 Doug Schaefer CLA 2008-05-27 22:43:45 EDT
Sorry Andrew, I was looking at patch size instead of who attached the patch. Of course you are correct. This is fine.

And thank you for this! Doxygen support is something people have been asking for a long time. We'll have to put together a demo on how to use it.

Cheers.
Doug.
Comment 21 Andrew Ferguson CLA 2008-05-30 11:02:07 EDT
(In reply to comment #20)
no problem :), after a panicked re-read of the IP policy I'm just relieved there wasn't a rule I'd missed

I'll add some screenshots to the New & Noteworthy wiki

Comment 22 Artem Pelenitsyn CLA 2010-06-25 05:54:37 EDT
(In reply to comment #21)
> (In reply to comment #20)
> no problem :), after a panicked re-read of the IP policy I'm just relieved
> there wasn't a rule I'd missed
> 
> I'll add some screenshots to the New & Noteworthy wiki

Are there any tutorials/advices for using doxygen support inside CDT?