Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367525

Summary: MediaWiki to Eclipse Help does not honour templateExcludes
Product: z_Archived Reporter: Elliott Baron <ebaron>
Component: MylynAssignee: Jeremie Bresson <dev>
Status: RESOLVED FIXED QA Contact: David Green <greensopinion>
Severity: normal    
Priority: P3 CC: akurtakov, danielhb, dev
Version: 1.5   
Target Milestone: 1.8.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip none

Description Elliott Baron CLA 2011-12-23 16:41:11 EST
When attempting to generate documentation for the Linux Tools Valgrind User Guide (http://wiki.eclipse.org/Linux_Tools_Project/Valgrind/User_Guide), we have two templates that cause the doc validation generation to fail. The error message is a missing </div> tag.

These templates are: {{#eclipseproject:technology.linux-distros}}
{{Linux_Tools}}
Linux_Tools expands to an Infobox that we use on all of our wiki pages.

This content is unnecessary for the user guide itself, but specifying templateExcludes="*eclipseproject*, Linux_Tools" or templateExcludes="*eclipseproject*, Infobox" does not remove the templates from the generated HTML files.

I was able to workaround this by temporarily removing the templates in the wiki to generate the docs, but I thought I would bring this issue to your attention.
Comment 1 David Green CLA 2012-01-04 18:40:05 EST
Thanks for the bug.
Comment 2 David Green CLA 2012-01-10 00:47:53 EST
I was able to reproduce the problem with the Linux_Tools template: it turns out there was an error in how we were escaping the underscore when building a regular expression.  The fix has been pushed to master and will be in the next build.

As for the eclipseproject template, I noticed that the template is referenced using the following syntax in the page:

bc. {{#eclipseproject:technology.linux-distros}}

What is the reason for the '#' character?  Currently Mylyn WikiText will not detect #eclipseproject as a template because of the leading '#' (only names matching the pattern [a-zA-Z_ :] are detected)
Comment 3 David Green CLA 2012-01-10 00:48:09 EST
Created attachment 209241 [details]
mylyn/context/zip
Comment 4 Alexander Kurtakov CLA 2012-01-10 09:47:15 EST
(In reply to comment #2)
> I was able to reproduce the problem with the Linux_Tools template: it turns out
> there was an error in how we were escaping the underscore when building a
> regular expression.  The fix has been pushed to master and will be in the next
> build.
> 
> As for the eclipseproject template, I noticed that the template is referenced
> using the following syntax in the page:
> 
> bc. {{#eclipseproject:technology.linux-distros}}
> 
> What is the reason for the '#' character?  Currently Mylyn WikiText will not
> detect #eclipseproject as a template because of the leading '#' (only names
> matching the pattern [a-zA-Z_ :] are detected)

The reason to have # in front is because this is the only way to hide the default edit/history/... toolbar-like line.
If I drop the # thetemplate is question is not applied but a "Template:Eclipseproject:technology.linux-distros" line is shown. 
It's quite possible that this is caused by me not having enough knowledge about wikis.
Comment 5 Alexander Kurtakov CLA 2012-01-10 09:50:11 EST
Looking at http://www.mediawiki.org/wiki/Help:Magic_words there is {{#language|#dateformat and etc. so this looks like smth supported.
Comment 6 Daniel Henrique Barboza CLA 2012-01-18 08:32:11 EST
Hello,

I've mentioned this bug in a page describing how to build Valgrind doc plug-in:

http://wiki.eclipse.org/Linux_Tools_Project/Building_Valgrind_Doc


And I would like to ask, to whoever who solves this bug in the future, to please remove the reference inside that page when the step of removing the templates isn't necessary anymore.

Thanks!
Comment 7 David Green CLA 2012-01-31 17:13:05 EST
I've updated template matching so that it now matches template names that begin with a hash '#' character.  This should resolve the problem where the template was not matched correctly. 

Feel free to give it another go (with the latest build) and let me know if it's working for you.
Comment 8 Daniel Henrique Barboza CLA 2012-02-15 12:56:42 EST
Hello,

I had to remove the following lines:

{{#eclipseproject:technology.linux-distros}}
{{Linux_Tools}}


From the http://wiki.eclipse.org/Linux_Tools_Project/PERF/User_Guide page to successfully run the ant build, otherwise validation fails.

This happened just now, using the latest build, and I think it's relevant for this bug.

Thanks.
Comment 9 David Green CLA 2012-02-28 13:21:56 EST
Thanks for the heads-up, it's relevant.
Comment 10 David Green CLA 2012-03-13 18:38:20 EDT
Unfortunately this won't make it for the release.
Comment 11 Jeremie Bresson CLA 2012-09-15 01:33:38 EDT
(In reply to comment #8)

Correct me if I am wrong, but this is a ant task that reproduce this bug:

<target name="to-eclipse-help" description="Converting to Eclipse Help" >
	<mediawiki-to-eclipse-help
			wikiBaseUrl="http://wiki.eclipse.org/"
			validate="true"
			failonvalidationerror="true"
			prependImagePrefix="images"
			formatoutput="true"
			defaultAbsoluteLinkTarget="doc_external"
			dest="${dist}"
			title="A test with Linux Tools"
			generateUnifiedToc="false"
			templateExcludes="*eclipseproject*, Linux_Tools">
	<!-- ${src}/Article/ -->
		<path name="Linux_Tools_Project/PERF/User_Guide" 
				title="PERF (User Guide)" 
				generateToc="true"/>
  </mediawiki-to-eclipse-help>
</target>


I have tested with:
* org.eclipse.mylyn.wikitext.core_1.8.0.I20120907-2057.jar
* org.eclipse.mylyn.wikitext.mediawiki.core_1.8.0.I20120907-2057.jar

I got 
BUILD SUCCESSFUL
Total time: 14 seconds

From what I have seen, "Linux_Tools" is not the problem: it is correctly excluded by the task.

But for your function call to "#eclipseproject" everything is not OK ("#eclipseproject" is probably a custom MediaWiki plug-in to modify the navigation bar on the left with content from eclipse.org) 

I got:

                     PERF (User Guide)
                                                Installing ->
-------------------------------------------------------------
{{#eclipseproject:technology.linux-distros}}

Overview

...

I assume that in the output the line "{{#eclipseproject:technology.linux-distros}}" is not expected.

Let me know if this is correct. 
I will try to understand why template resolver do not handle this well.
Comment 12 Jeremie Bresson CLA 2012-09-18 13:50:38 EDT
I think I have fixed the bug:
https://git.eclipse.org/r/7804

Problem was @{{#eclipseproject:technology.linux-distros}}@ contains "." and "-". 

These 2 chars were not expected in TemplateProcessor.templatePattern pattern.
Comment 13 Jeremie Bresson CLA 2012-09-22 01:42:53 EDT
Questions answered in Gerrit.
Comment 14 David Green CLA 2012-10-11 15:52:46 EDT
review submitted, thanks Jeremie.