Update the NAV2015 ToC.XML

The ToC.XML is a simple recursive structure with entries like this:

<?xml version="1.0" encoding="utf-8"?>
<Node Name="DynamicsHelp" DisplayName="Help" Page="conGettingStarted.htm">
    <Node Name="TechRef" DisplayName="Technical Reference" Page="conTechnicalReference.htm">
      <Node Name="CSIDERef" DisplayName="C/SIDE Reference Guide" Page="conCSIDEReferenceGuide.htm" />
      <Node Name="DevEnvCmds" DisplayName="Development Environment Commands" Page="conDevelopmentEnvironmentCommands.htm" />
      <Node Name="CSIDEwindows" DisplayName="Windows Overview" Page="conWindowOverviews.htm" />
    </Node>
    <Node Name="Upgrade" DisplayName="Upgrading to Microsoft Dynamics NAV 2015" Page="oriUpgradingToNAVCrete.htm">
      <Node Name="MigratingToMultitenancy" DisplayName="Migrating to Multitenancy" Page="conMigratingTenantDatabases.htm" />
    </Node>
  </Node>
</Node>

Just a name, a title and a page, and that looks very similar to the structure we already have in place from the manual. So we do here, is run through our own Structure.XML, and inserts matching entries into the ToC.

This is the main piece of code that will generate the html files, and update the ToC at the same time:

public bool GenerateAllContentAsHtml()
        {
            XDocument TOC = XDocument.Load(ConfigurationManager.AppSettings["input-toc"]);

            XElement root = (from xml2 in TOC.Descendants("Node")
                             where xml2.Attribute("Name").Value == ConfigurationManager.AppSettings["projectname"]
                             select xml2).FirstOrDefault();
            if (root == null)
            {
                root = GetNode(ConfigurationManager.AppSettings["projectname"], Data.manual.Title, ConfigurationManager.AppSettings["projectname"] + ".htm");
                TOC.Element("Node").Nodes().FirstOrDefault().AddAfterSelf(root);
            }
            root.Nodes().Remove(); // If we already have our stuff in this TOC remove it first

            StringBuilder ChapterList = new StringBuilder();
            foreach (var chapter in Data.manual.Chapters)
            {
                root.Add(GenerateChapter(chapter));
                string str = "<a href=\"" + ConfigurationManager.AppSettings["projectname"] + "_" + chapter.No + ".htm\" xmlns=\"http://ddue.schemas.microsoft.com/authoring/2003/5\">";
                str += chapter.Title + "</a><br>";
                ChapterList.Append(str);
            }

            Article preface = Data.Articles.Find(m => m.ID == Data.manual.Preface.ID);
            if (preface == null)
            {
                preface = new Article()
                {
                    ID = Data.manual.Preface.ID,
                    Text = "TODO: Article " + Data.manual.Preface.ID,
                    Title = "TODO: Article Caption " + Data.manual.Preface.ID
                };
            }
            StringBuilder topic = new StringBuilder(File.ReadAllText(ConfigurationManager.AppSettings["helppage-html"]));
            topic.Replace("$1$", preface.Title);
            topic.Replace("$1$", preface.Title);
            topic.Replace("$2$", ConvertMarkdown(preface.Text, "html") + ChapterList);
            File.WriteAllText(
                ConfigurationManager.AppSettings["output-path-helpserver"] + @"\" +
                ConfigurationManager.AppSettings["projectname"] + ".htm", topic.ToString());

            TOC.Save(ConfigurationManager.AppSettings["output-toc"]);
            return false;
        }

The NAV Based Help Editor System

When installing the FOB file from the download, you will get 2 tables and some support objects. Its important to say right up, that these objects are not “production quality” they are simply good enough for our use. That means hard-coded path and name of a an Markdown editor (Called MarkdownPad Pro) and no nice icons – You get the pictures, these are objects developed for developers, and once it works – that fine 🙂 Fell free to extend them.

There are two types of help texts that you can maintain with these objects:

1. Articles – Very simple list of articles.
2. Content Help – This is help to objects (and fields) It is possible to populate this table with all the entries needed.

The last piece in the NAV objects is a XML Port to import/export the all the help. This is done in XML format and of-cause, this file

Running the Help processor

To get the whole thing running, take a look at the HelpTest.exe.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="miktex-path" value="C:\Program Files (x86)\MiKTeX 2.9\miktex\"/>
    <add key="pandoc-path" value="C:\Projects\Help\Tools\"/>
    <add key="template-xml" value=".\template.xml"/>
    <add key="content-xml" value=".\NAV.xml" />
    <add key="structure-xml" value=".\structure.xml"/>
    <add key="projectname" value="Demo Help"/>
    <add key="helppage-html" value=".\HelpPage.html"/>
    <add key="input-toc" value=".\input-toc.xml"/>
    <add key="output-toc" value=".\output\output-toc.xml"/>
    <add key="output-path-helpserver" value=".\output"/>
    <add key="output-path-manual" value=".\output"/>
  </appSettings>
  <startup> 
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
</configuration>

You  need to install the following to be ready:

MikTex 2.9 http://miktex.org/download

Pandoc https://github.com/jgm/pandoc/releases

And update the paths in the config file

After this you need to update all the setup paths and xml files. These should point to the content from the ZIP file.

Running HelpTest.exe from a prompt should generate output that looks a bit like this: (This is the output from Foqus Finance)

Building manual
Generate Topic 6030550 (Table)
Generate SubTopic 6030551 (Table)
Generate SubTopic 6030553 (Table)
Generate SubTopic 6030554 (Table)
Generate SubTopic 6030555 (Table)
Generate SubTopic 6030556 (Table)
Generate SubTopic 6030569 (Table)
Generate SubTopic 6030558 (Table)
Generate SubTopic 6030559 (Table)
Generate SubTopic 6030568 (Table)
Generate SubTopic 6030567 (Table)
Generate SubTopic 6030581 (Table)
Generate Topic 6030562 (Table)
Generate Topic StageSales (Article)
Generate Topic StageEstab (Article)
Generate Topic StageAdmin (Article)
Generate Topic StageRearr (Article)
Generate Topic StageArchive (Article)
Generate Topic 6030560 (Table)
Generate Topic 6030561 (Table)
Generate Topic 6030582 (Table)
Generate Topic 6030695 (Table)
Generate Topic 6030696 (Table)
Generate Topic 6030740 (Table)
Generate Topic 6030741 (Table)
Generate Topic 6030650 (Table)
Generate Topic 6030666 (Table)
Generate Topic 6030563 (Table)
Generate Topic 6030565 (Table)
Generate Topic 6030651 (Table)
Generate Topic 6030700 (Table)
Generate Topic 6030557 (Table)
Generate Topic 6030703 (Table)
Generate Topic 6030652 (Table)
Generate Topic 6030680 (Table)
Generate Topic 6030653 (Table)
Generate Topic 6030654 (Table)
Generate Topic 6030655 (Table)
Generate Topic 6030656 (Table)
Generate Topic 6030677 (Table)
Generate Topic 6030679 (Table)
Generate Topic ContractFlow (Article)
Generate SubTopic 6030901 (Table)
Generate SubTopic 6030902 (Table)
Generate SubTopic 6030904 (Table)
Generate Topic 6031008 (Table)
Generate SubTopic 6031009 (Table)
Generate SubTopic 6031010 (Table)
Generate SubTopic 6031011 (Table)
Generate SubTopic 6031000 (Table)
Generate SubTopic 6031001 (Table)
Generate SubTopic 6031002 (Table)
Generate SubTopic 6031003 (Table)
Generate SubTopic 6031004 (Table)
Generate SubTopic 6031005 (Table)
Generate SubTopic 6031006 (Table)
Generate SubTopic 6031007 (Table)
Generate Topic CostSetup (Article)
Generate SubTopic 6030659 (Table)
Generate SubTopic 6030702 (Table)
Generate SubTopic 6030675 (Table)
Generate Topic TaskSetup (Article)
Generate SubTopic 6030658 (Table)
Generate SubTopic 6030701 (Table)
Generate SubTopic 6030676 (Table)
Generate SubTopic 6030571 (Table)
Generate SubTopic 6030572 (Table)
Generate Topic ServiceIns (Article)
Generate SubTopic 6030566 (Table)
Generate SubTopic 6030663 (Table)
Generate SubTopic 6030664 (Table)
Generate SubTopic 6030669 (Table)
Generate SubTopic 6030670 (Table)
Generate SubTopic 6030671 (Table)
Generate SubTopic 6030672 (Table)
Generate SubTopic 6030673 (Table)
Generate Topic CreditApprov (Article)
Generate SubTopic 6030950 (Table)
Generate SubTopic 6030951 (Table)
Generate SubTopic 6030952 (Table)
Generate SubTopic 6030953 (Table)
Generate SubTopic 6030954 (Table)
Generate SubTopic 6030955 (Table)
Generate Topic FoqusDocSetup (Article)
Generate SubTopic 6030910 (Table)
Generate SubTopic 6030911 (Table)
Generate SubTopic 6030912 (Table)
Generate SubTopic 6030913 (Table)
Generate SubTopic 6030914 (Table)
Generate SubTopic 6030915 (Table)
Generate SubTopic 6030916 (Table)
Generate SubTopic 6030920 (Table)
Building helpserver files
Generate Topic 6030550 (Table)
Generate Topic 6030562 (Table)
Generate Topic StageSales (Article)
Generate Topic StageEstab (Article)
Generate Topic StageAdmin (Article)
Generate Topic StageRearr (Article)
Generate Topic StageArchive (Article)
Generate Topic 6030560 (Table)
Generate Topic 6030561 (Table)
Generate Topic 6030582 (Table)
Generate Topic 6030695 (Table)
Generate Topic 6030696 (Table)
Generate Topic 6030740 (Table)
Generate Topic 6030741 (Table)
Generate Topic 6030650 (Table)
Generate Topic 6030666 (Table)
Generate Topic 6030563 (Table)
Generate Topic 6030565 (Table)
Generate Topic 6030651 (Table)
Generate Topic 6030700 (Table)
Generate Topic 6030557 (Table)
Generate Topic 6030703 (Table)
Generate Topic 6030652 (Table)
Generate Topic 6030680 (Table)
Generate Topic 6030653 (Table)
Generate Topic 6030654 (Table)
Generate Topic 6030655 (Table)
Generate Topic 6030656 (Table)
Generate Topic 6030677 (Table)
Generate Topic 6030679 (Table)
Generate Topic ContractFlow (Article)
Generate SubTopic 6030901 (Table)
Generate SubTopic 6030902 (Table)
Generate SubTopic 6030904 (Table)
Generate Topic 6031008 (Table)
Generate Topic CostSetup (Article)
Generate SubTopic 6030659 (Table)
Generate SubTopic 6030702 (Table)
Generate SubTopic 6030675 (Table)
Generate Topic TaskSetup (Article)
Generate SubTopic 6030658 (Table)
Generate SubTopic 6030701 (Table)
Generate SubTopic 6030676 (Table)
Generate SubTopic 6030571 (Table)
Generate SubTopic 6030572 (Table)
Generate Topic ServiceIns (Article)
Generate SubTopic 6030566 (Table)
Generate SubTopic 6030663 (Table)
Generate SubTopic 6030664 (Table)
Generate SubTopic 6030669 (Table)
Generate SubTopic 6030670 (Table)
Generate SubTopic 6030671 (Table)
Generate SubTopic 6030672 (Table)
Generate SubTopic 6030673 (Table)
Generate Topic CreditApprov (Article)
Generate SubTopic 6030950 (Table)
Generate SubTopic 6030951 (Table)
Generate SubTopic 6030952 (Table)
Generate SubTopic 6030953 (Table)
Generate SubTopic 6030954 (Table)
Generate SubTopic 6030955 (Table)
Generate Topic FoqusDocSetup (Article)
Generate SubTopic 6030910 (Table)
Generate SubTopic 6030911 (Table)
Generate SubTopic 6030912 (Table)
Generate SubTopic 6030913 (Table)
Generate SubTopic 6030914 (Table)
Generate SubTopic 6030915 (Table)
Generate SubTopic 6030916 (Table)
Generate SubTopic 6030920 (Table)
Done

MiKTex might show some warnings like this, ignore those 🙂

This is makeindex, version 2.15 [MiKTeX 2.9] (kpathsea + Thai support).
Scanning input file FoqusFinance.idx.....done (1271 entries accepted, 1 rejected).
Sorting entries.............done (14618 comparisons).
Generating output file FoqusFinance.ind.....done (925 lines written, 0 warnings)
.
Output written in FoqusFinance.ind.
Transcript written in FoqusFinance.ilg.

** WARNING ** Couldn't open font map file "kanjix.map".

After this, oyu should have a PDF, a new ToC.xml and a bunch of HTML Files.