How to unregister Documentation Tool Window and register a new custom Documentation tool window?

Answered

Hello, I have a request to enrich Documentation tool window, and show more images inside it and open hyperlinks inside it.

Would you please kindly advise , is there any way to unregister default Documentation Tool Window and register a new one which would have more customized functions?

Or is there any way to override default Documentation Tool Window ? 

Thanks!!

7 comments
Comment actions Permalink

Could you give more details about

1) "show more images inside it"

2) "open hyperlinks inside it"

 

for 2) check com.intellij.lang.documentation.DocumentationProviderEx#getDocumentationElementForLink

 

1
Comment actions Permalink

@Yann Cebron

 

Thank you for this quick reply.

for 1)

1) like show images inside documentation tool windows and show tables, etc. In all , we'd like to show complex html contents inside this documentation tool window or customized tool window which overrides documentation tool window. For example , show the whole content of www.amazon.com, but not that complex

0
Comment actions Permalink

I would suggest to create a custom additional action and tool window/popup window for such case - assuming such documentation is generated for special kinds of files/symbols.

1
Comment actions Permalink

Thanks

Here is the problem. we have http links in JavaDoc , right now, we will open a browser outside of IDEA to show this link.

We have a request of showing the content of this link inside IDEA in documentation tool window or custom tool window. 

I don't know how to let IDEA treat http hyperlink and do not open browser

0
Comment actions Permalink

You can handle links in your documentation by implementing `com.intellij.lang.documentation.DocumentationProvider#getDocumentationElementForLink` in your provider. If you just want to display some content on link navigation, you can also make your provider implement `ExternalDocumentationHandler` (in particular `canFetchDocumentationLink` and `fetchExternalDocumentation`). This will require fetching the content in the provider, if it's available somewhere outside the application.

0
Comment actions Permalink

@Dmitry Batrak cc:Yann Cebron
I am working on a similar task like Sonicning. I need to implement custom DocumentationProvider. My documents will have some links (to http pages or local files). I need to intercept 'open link' event and override business logic to open those links inside IDE's custom tool window browser.

1) I followed your advice to implement `com.intellij.lang.documentation.DocumentationProvider#getDocumentationElementForLink` but for some reason this method is NEVER invoked. My code:
plugin.xml
<lang.documentationProvider language="JAVA" implementationClass="com.xxx.xxx.xxx.xxx.DDocumentationProvider" />

DDocumentationProvider.java

public class DDocumentationProvider implements DocumentationProvider {
@Nullable
@Override
public String getQuickNavigateInfo(PsiElement psiElement, PsiElement psiElement1) {
return null;
}

@Nullable
@Override
public List<String> getUrlFor(PsiElement psiElement, PsiElement psiElement1) {
return null;
}

@Nullable
@Override
public String generateDoc(PsiElement psiElement, @Nullable PsiElement psiElement1) {
return null;
}

@Nullable
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object o, PsiElement psiElement) {
return null;
}
@Nullable
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
System.out.println("HELLO from getDocumentationElementForLink");
return null;
}

}

 


2) I didn't find a way to implement 'ExternalDocumentationHandler'. Would you be so kind as to give some examples? (do we need to register it at plugin.xml?)

 

Thank you in advance!

 

0
Comment actions Permalink

@2111311792 See javadoc for DocumentationProvider#getDocumentationElementForLink - it will be called only for links using DocumentationManagerProtocol#PSI_ELEMENT_PROTOCOL. You can debug DocumentationManager#navigateByLink if something still won't work for you to find out the reason.

0

Please sign in to leave a comment.