Making Multi-Level Anchors Work With globalindex.py for Sphinx

One of the issues I’ve come across when using Sphinx (awesome application) for writing documentation is that the table of contents disappear when using the singlefile format (which generates the documentation as one large page instead of having to click through to other files).

Luckily Matteo Franchin had the same issue, and created a small extension for Sphinx that allows you to add a TOC to SingleHTML builders as well! The problem I discovered after a while is that it ends up adding redundante HTML anchors for each level when resolving the TOC, where it ends up generating #html#anchors like that. Which doesn’t work.

I solved the issue (.. for my simple case, this is still a hack) by adding regular expression that removes any HTML anchors that are followed by another HTML-anchor (and could very possibly eat a lot more in edge cases, but hey, it works for me!).

rendered_toctree = re.sub(r'(#[^ "]+)#', '#', rendered_toctree);

The lines around line 59 should then look like:

            rendered_toctree = builder._get_local_toctree(docname, **kwargs)
            rendered_toctree = re.sub(r'(#[^ "]+)#', '#', rendered_toctree);
            node['content'] = rendered_toctree

Apache 2.4 Failing to Recognize Virtual Hosts

After upgrading from Apache 2.2 to 2.4 in a Windows development environment, all my virtualhosts stopped working. I could add syntax errors to the files which would make Apache refuse to start up, or get notices about invalid document roots, but the virtual host server names just wouldn’t catch on.

After removing the reference to Include conf/extra/httpd-vhosts.conf things suddenly started working! Weird. The reason seems to be that the default vhost referenced in httpd-vhosts.conf uses _default_ instead of * to reference the virtualhost name. I’ve used * in all my configuration files, and apparently Apache refuses to reference any * references if it hits a _default_ name in the VirtualHost configuration first. That seems weird, so if someone has any more information about what’s causing this, I’m very interested.

My setup now works again, so I’m not going to start digging into the source to find the reason for this just yet. :-)

AH01753: access check of ‘127.0.0.1’ to /xxx/ failed, reason: unable to get the remote host name

This error message can be caused by placing an IP instead of a hostname in a Require host statement in Apache 2.4+. After porting some old access rules to Apache 2.4 I had used Require host 127.0.0.1 instead of the correct Require ip 127.0.0.1. Switched it, and ahoy! It now works.