The gods of irony are shining on me

The goal for this evening was to make a few minor, easy changes and then get to work on one of the missing features: the ability to open up package files and URL’s from a help link. The second minor change that I embarked on ended up taking me down a rabbit hole of the most ironic proportions, and so as a result I only got a couple of things done and not nearly what was on my list.

That’s just the way it goes sometimes, though.

Most of my changes were supposed to be small cosmetic tweaks to enhance usability. For example, while working on the ability to add help to a package that doesn’t have it yet, I taught my brain that the command palette entry for that contains the text Add. However, when you want to add a new help file to a package, the command is Create instead.

As small as it sounds, that got in my way more than a couple of times last night while I was working on the help text. Possibly if I hadn’t used the other command a hundred times it would be more intuitive, but for now the command has been changed in the palette to say Add Help File instead, which on the whole just feels better.

The next change is where I ran into some issues which were sort of ironic in that they were caused by the very code that I added to stop this exact kind of error from happening.

When the help index loader processes an index file, it comes up with a global list of topics contained within that help package by collecting the topics from all of the defined help files. That allows the system to easily determine where a link is pointing or whether a topic is known at all. While it’s doing this, if it detects that a help file hasn’t defined a topic that points to itself, it creates one automatically.

The reason for that is to ensure that help files can’t be orphaned; since the header always includes the name of the help file, having a topic ensures that even if the file entry in the help index is empty, you can still link to the file.

Previously if there was no topic for the help file, a default would be used that pointed out directly that the person who wrote the help index didn’t create the topic yet by providing a caption to that effect. While working on help last night I realized that in most cases I was creating the topic manually just to set the caption to the string that I had already said was the title of the page.

I’m not sure why I didn’t think of it at the time, but the more logical solution would be to use that already defined title to set the caption for the topic. If you do it that way, then the only time you have to provide your own custom topic entry is if you want the help topic to have a different caption than the title of the page itself, which I only did once (one works better in the TOC and one works better in the file itself).

Here I ran into problems that sent me down a weird spiraling rabbit hole of woe, because validictory, which I included in the project specifically to validate that the data in the help index follows the schema, seems to have some weird bug in it that causes it to throw an exception if it expects an array to have at least one item but it has none.

To be fair I’m not sure if I’m not just doing something stupid or what, but in the interests of not going crazy I just included a new exception handler to catch unknown exceptions while validating the help so that when it fails it’s at least not a really spectacular stack trace. At some point after Devember I’ll have to look into that in more detail to see if I maybe need a different package instead or something. In the interim I’ve just made a note to look into that later, since I was already going to look into how validictory generates really awful error messages.

The last change that I got to tonight before calling it a night due to exhaustion was to include a help index function. This is sort of like the table of contents, except that it just shows every link that exists in the help system. This is sort of a poor man’s help search, since it allows you to narrow in on a topic that you want to look at based on key words, assuming that the anchor text is descriptive enough of what’s happening.

In fact the table of contents function degenerates into an index if the help author doesn’t provide a TOC structure in the index, so in some cases the command might be redundant, but I choose to hope people will want to take more control over that  aspect.

Now that the index is in place I’m sorely tempted to merge the new command with the existing TOC command, since they’re mostly the same anyway. I’m trying not to fall into the urge to do that because there is a lot of refactoring that needs to happen to clean things up.

For now though, it’s bed time. However the list of items to work on, take note of, or think about more has almost topped out at 100 items (although some of them are checked off as done), so it seems like I’m making less progress as time goes forward.

Pretty sure that’s par for the course, though.