Posted 6 years ago by William Sardar
Version: 13.1.0582
Avatar

Hi

I have a SyntaxEditor with completion working correctly.

I would like to access the Actipro XML parsed documentation database that gets used in Completion List and Parameter Info popups.

I need to provide a custom info box about the methods that are available to the user and would like to use this info.

Do I need to use a DocumentationProvider, or access one that already exists?

 

Thank you

Comments (5)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi William,

Each IAssembly (IProjectAssembly or IBinaryAssembly) has a Documentation property that returns an IAssemblyDocumentation object, if docs are available for that assembly.  That has methods on it where you can pass a type or member definition and it will return the appropriate IDocumentationProvider to you.  Then use that to obtain the parsed documentation.


Actipro Software Support

Posted 6 years ago by William Sardar
Avatar

Thank you for the tip. 

I now need to create an ITypeDefinition. I have the System.Type of the class I want to get documentation for.

Could you provide any further examples? If this is documented elsewhere and I have missed it, please accept my apologies.

William

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi William,

You'd need to have our code load up the assembly that contains the Type.  If you want the assembly to be referenced by your IProjectAssembly, do code similar to what is shown in the Assemblies topic (in the .NET add-on documentation).  Or if you want to load the IBinaryAssembly independently, you can get the assembly repository you've set up at AmbientAssemblyRepositoryProvider.Repository, and then call its Load method by passing the Assembly.  That will return the IBinaryAssembly used by our code.

Once you have the IBinaryAssembly (through either method above), you can look at its Namespaces collection to find the namespace of the Type you want.  Then look for the appropriate ITypeDefinition in that.


Actipro Software Support

Posted 6 years ago by William Sardar
Avatar

Thank you.

var project = this.document.Language.GetService<IProjectAssembly>();
var assemblyRef = project.AssemblyReferences.FirstOrDefault(ar => ar.Assembly.Name == MyMethod.DeclaringType.Assembly.GetName().Name);
INamespaceDefinition nsDef = null;
if (null != assemblyRef)
{
nsDef = assemblyRef.Assembly.Namespaces.First(n => n.FullName == MyMethod.DeclaringType.Namespace);
}
ITypeDefinition typeDef = null;
if (null != nsDef)
{
typeDef = nsDef.Types.First(t => t.FullName == MyMethod.DeclaringType.FullName);
}
ITypeMemberDefinition typeMemberDef = null;
if (null != typeDef)
{
typeMemberDef = typeDef.Members.First(m => m.Name == MyMethod.Name);
}
IDocumentationProvider docProvider = null;
if (null != typeMemberDef)
{
docProvider = project.Documentation.GetDocumentation(typeMemberDef);
}

 

I have tried the below code but the GetDocumentation method returns null, despite typeMemberDef containing a valid TypeMemberDefinition object.

In the editor I get documentation when I try to insert the method.

Have you got any advice?

Thank you

[Modified 6 years ago]

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi William,

You are sure that the last line is getting executed and is returning null? If so then it would be my guess that documentation isn't available for that method. But that doesn't make sense if you are seeing it in IntelliPrompt.

It's hard to say what it could be without something simple to debug. If you'd like us to look into it, please make a new simple sample project that shows the issue and email that to our support address. Try to keep it as minimal as possible, reference this post, and rename the .zip file extension so it doesn't get spam blocked. Thanks!


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.