External URLS prior to 1.32, compatibility

2004-12-03
2012-09-14
  • Ryan Nickell
    Ryan Nickell
    2004-12-03

    Now that you've moved the output directories around, etc., is there any way to hack Natural Docs so that any external links to specific pages made prior to 1.32 will link to the correct pages without having to replace every url? For example, the user goes to the url:

    http://rofl.legendz.com/client/src/docs/roadmap-txt.php#RofL_Client_Milestone_7

    (which is no longer valid) and it would redirect to the url:

    http://rofl.legendz.com/client/src/files/docs/roadmap-txt.php#RofL_Client_Milestone_7

    If so, then what modules would need to be hacked to achieve this? I ask this because 1) I have a lot of external links to my documentation that worked prior to 1.32, on my forums, bugtracker, etc., and 2) some of these external links I don't have control over, such as...uh, your website, for obvious reasons.

    Thanks for updating your anchor for me, btw, and thanks in advance for your reply.

     
    • Greg Valure
      Greg Valure
      2004-12-03

      NaturalDocs::Builder::HTMLBase->OutputFileOf().

      Remove this line:

      $outputDirectory = NaturalDocs::File->JoinPaths( $outputDirectory,
      

      'files' . ($inputDirectoryName != 1 ? $inputDirectoryName : ''), 1 );

      If you use multiple input directories, you'll have to replace it with something. Otherwise you can leave it off completely.

       
      • Ryan Nickell
        Ryan Nickell
        2004-12-04

        First off, thanks for your reply. With what you said, I was able to get Natural Docs to generate the files that I needed to edit to get the effect that I wanted. From now on, if a user was to go to an obsolete url, such as the following:

        http://rofl.legendz.com/client/src/docs/roadmap-txt.php#RofL_Client_Milestone_7

        it will display a message saying it will jump to the updated url automatically, and then it will jump straight to the top of this page:

        http://rofl.legendz.com/client/src/files/docs/roadmap-txt.php

        Second, what I want to know is if there is any way that something like this can be built into Natural Docs, as a compatibility feature/option, so that it can generate such redirect pages, like the ones I made, instead of manually having to do them?

        Thanks again

        • Ryan
         
        • Greg Valure
          Greg Valure
          2004-12-04

          One way to do it would be to make a separate function, CompatibilityOutputFileOf() or something, that makes names the old way while the original keeps using the new way. Then in NaturalDocs::Builder::HTML->BuildFile() you just output a second redirection file as well.

          I don't know how many people do deep linking; we'll see if anyone else says anything. But keeping the compatibility files around keeps the potential for naming conflicts around as well, and that's what I needed to get rid of. One generated file overwriting another one that was supposed to be separate. It's a remote concern now but won't always be as the feature set expands.

          Now that only Natural Docs controls the top-level doc directory, there's no chance of conflict and I should be able to expand without ever doing this kind of link-breaking reorganization again.