# Dynamic topics

In addition to static HTML files present in doc.zip or file system under plug-in directory, help can display documents that are dynamically generated by the documentation plug-in. Such plug-in needs to contain Java code capable of producing contents that would otherwise be read from static files by help system. If a class implementing org.eclipse.help.IHelpContentProducer is contributed by a plug-in to help system using org.eclipse.help.contentProducer extension point, the help system will call getInputStream for every document accessed from this plug-in. If that results in not null InputStream, it will be sent to the browser for displaying. If IHelpContentProdcuer returns null, help system will default to searching doc.zip and plug-in directory for a document.

#### Content producer example

For example, an implementation of IHelpConentProducer as follows:

    package com.my.company.doc;
    public class DynamicTopics implements IHelpContentProducer {
    	public InputStream getInputStream(
    		String pluginID,
    		String name,
    		Locale locale) {
    		if (name.indexOf("dynamic") >= 0)
    			return new ByteArrayInputStream(
    				("<html><body>Content generated "
    					+ new Date().toString()
    					+ ".</body></html>")
    					.getBytes());
    		else
    			return null;
    	}
    }

identified by extension in plugin.xml file as:

    <extension point="org.eclipse.help.contentProducer"
        name="dynamicTopics"
        id="my.company.doc.dynamicTopics">
        <contentProducer producer="com.my.company.doc.DynamicTopics" />
    </extension>

will produce an HTML document content for all document references that have a word "dynamic" as part of the path or file name.

#### Constraints

A plug-in has a complete freedom of the method of method or underlying framework that is used to produce the content. It should however ensure that content is generated in correct language and encoded accordingly that a browser can display it. A locale used by the user is provided to the getInputStream method. If it is incapable of providing translatable content, it should default to content for the default locale of the platform.