Search code examples
c++mediawikimediawiki-templatessemantic-mediawiki

Collision between Semantic MediaWiki and C++ namespace syntax


To describe some C++ classes and provide how-to's, we are successfully using a MediaWiki-based wiki for years. The documented classes are typically defined in a C++ namespace, so we use wiki pages named after the cppnamespace::classname convention.

One year ago, the Semantic MediaWiki (SMW) extension was enabled for the wiki.

Today, I started browsing the wiki statistics and I found some suspicious attributes "used but not defined". As I discovered, those were caused by a collision of a special meaning the SMW attribute syntax applied to the C++ namespace separator :: that causes issues on wiki pages with links to pages named by fully qualified classes. SMW always shortens the name to the class name.[1]

If I write in wiki text,

 [[MyNamespace::MyClass]]
 [[MyNamespace::MyClass|MyNamespace::MyClass]]
 [[MyClass|MyNamespace::MyClass]]

...the rendered wiki page will display,

MyClass MyClass MyClass

...and the page that is linked to is MyClass in every case.

I'd usually handled problems of this kind by introducing a new MediaWiki template[2]. But I'm unsure about the best solution in this special case, because there are many pages that will be affected. So I'm interested in previous experiences with it. (neither Google nor SO did help so far)

If you had the same problem, what solution did you find?


  • [1] Addition: Version information: MediaWiki 1.23.4 with Semantik MediaWiki 2.0
  • [2] Addition: I found out by trying, that building a MediaWiki template for this purpose is difficult, if not impossible...

Solution

  • According to http://semantic-mediawiki.org/wiki/Help:Properties_and_types

    To make an ordinary link with :: without creating a property, escape the markup with a colon in front, e.g. The [[:C++ :: operator]].