0

I would like to generate documentation in a Dancer application in the same way that Mojolicious does with Mojolicious::Plugin::PODRenderer, I mean in the browser, under the /perldoc path.

Does somebody knows a module that can help? I found no ready-made plugin for Dancer. If it don't exist, any recommandation is welcome.

Jonas
  • 121,568
  • 97
  • 310
  • 388
smonff
  • 3,399
  • 3
  • 36
  • 46
  • 1
    As a developer of Mojolcious, may I ask, is there some external reason why you are not developing a Mojolicious application? If Dancer is for you then great, but if you had some difficulty with Mojo and moved on, I would be happy to help. – Joel Berger Mar 26 '14 at 00:44
  • I appreciate your proposal for help Joel. I am currently testing both Frameworks. I'm searching for the one that will have the most documentation and simple examples for common things understandable by an intermediate-beginner. I am not interesting by extreme performance facts. I have read about the Dancer-likes-CPAN VS Mojo-has-no-dependencies debate, and admit it don't really helps to choose. Both are dead simple to start with (dependencies or not), but the fact you answer first could help me to choose. The PODRenderer plugin is very interesting and maybe I would like to hack a bit with it. – smonff Mar 26 '14 at 07:43
  • 1
    We like to think we have very good documentation. To address some common questions, first read the doc for [Mojolicious::Lite](http://mojolicio.us/perldoc/Mojolicious/Lite) (which is the tutorial and should not be skipped) then read the guides in the order seen [here](http://mojolicio.us/perldoc). Also, individual class docs are reference and not intended as tutorial. – Joel Berger Mar 28 '14 at 19:06
  • This is a precious thing to have a path to follow into the guides an tutorials and not skipping the *::lite* part. – smonff Mar 29 '14 at 09:20
  • Many people skip the `::Lite` tutorial, because they are only interested in a full app. However many important concepts are introduced and the lite syntax is used throughout the documentation. It really shouldn't be skipped. Enjoy! – Joel Berger Mar 30 '14 at 17:44

1 Answers1

1

Porting Mojolicious' PODRenderer to Dancer should be fairly simple - it's an example plugin and the code is fairly short. I've done this for my own use in my CGI framework at work.

https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/PODRenderer.pm#L34

Essentially what the plugin does is define the route /perldoc/:module to call the _perldoc method; the _perldoc method uses Pod::Simple::Search to find a documentation file matching the module param in the @INC directories; If it doesn't, it redirects the search to MetaCPAN. If it does, it uses Pod::Simple::HTML to convert the documentation to HTML, which is then tidied up with Mojo::DOM and wrapped in a lovely template.

Finding the location of that template is left as an exercise for... oh, nevermind, here it is: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/templates/perldoc.html.ep

smonff
  • 3,399
  • 3
  • 36
  • 46
Dotan Dimet
  • 490
  • 3
  • 5
  • That last link is now 404. New location (pinned at the current latest release v7.03): https://github.com/kraih/mojo/blob/v7.03/lib/Mojolicious/resources/templates/mojo/perldoc.html.ep – Christopher Causer Aug 24 '16 at 08:27