digitalmars.D.learn - Generate PDF or HTML of source
- Anonymouse (13/13) Mar 16 I want to generate PDFs of the individual source files of my
- Adam D. Ruppe (8/10) Mar 16 adrdox --help
- Anonymouse (4/14) Mar 16 Oh, neat! I missed that option.
- Adam D. Ruppe (11/13) Mar 16 I never even considered someone would try to print it lol. Should
- Anonymouse (12/25) Mar 16 The use-case is that I want to put it all on an e-ink reader to
- Adam D. Ruppe (14/16) Mar 16 Yeah, I specifically disabled word wrap for code blocks because I
- Anonymouse (3/19) Mar 16 The wrapping [looks a bit funky](https://i.imgur.com/aYQT5Tc.png)
- Andrea Fontana (5/19) Mar 17 `dub run dscanner -- --highlight source/app.d`
I want to generate PDFs of the individual source files of my project. Preferably with syntax highlighting, but if pressed I could live without it for this particular case. I would like line numbers though. HTML is fine too as I could just print them to PDF. `dub build -b docs` and `ddox` and `adrdox` etc can all generate API summary documentation, but I have a need for the source files themselves. So far the best I've managed is to browse to the pages for the source files on GitHub and print those to PDF. It works, but you get the top of the page with the menu etc included, and it's put simply a pain to manually do when you have 75 source files. Is there any elegant solution I'm missing?
Mar 16
On Sunday, 16 March 2025 at 16:26:55 UTC, Anonymouse wrote:`adrdox` [...] but I have a need for the source files themselves.adrdox --help -u --genSource Generate annotated source use that -u thing and it spits out source too with links everywhere just like you see at https://opendlang.org/library/arsd.characterencodings.convertToUtf8.html "see implementation" https://opendlang.org/library/source/arsd.characterencodings.d.html#L71
Mar 16
On Sunday, 16 March 2025 at 17:07:45 UTC, Adam D. Ruppe wrote:On Sunday, 16 March 2025 at 16:26:55 UTC, Anonymouse wrote:Oh, neat! I missed that option. Is getting rid of the sidebar non-trivial? I get https://i.imgur.com/ropgZWj.png when printing to PDF.`adrdox` [...] but I have a need for the source files themselves.adrdox --help -u --genSource Generate annotated source use that -u thing and it spits out source too with links everywhere just like you see at https://opendlang.org/library/arsd.characterencodings.convertToUtf8.html "see implementation" https://opendlang.org/library/source/arsd.characterencodings.d.html#L71
Mar 16
On Sunday, 16 March 2025 at 17:27:22 UTC, Anonymouse wrote:Is getting rid of the sidebar non-trivial? I get https://i.imgur.com/ropgZWj.png when printing to PDF.I never even considered someone would try to print it lol. Should be easy enough to add some css like ``` media print { #page-nav { display: none !important; } } ``` to the end of style.css in your generated docs folder then refresh it in your browser. Can add other things to hide there too if you want.
Mar 16
On Sunday, 16 March 2025 at 17:33:43 UTC, Adam D. Ruppe wrote:On Sunday, 16 March 2025 at 17:27:22 UTC, Anonymouse wrote:The use-case is that I want to put it all on an e-ink reader to pore over and annotate it as if it were written out on paper. [This particular one](https://supernote.com/pages/supernote-manta) doesn't do HTML, but PDF works very well.Is getting rid of the sidebar non-trivial? I get https://i.imgur.com/ropgZWj.png when printing to PDF.I never even considered someone would try to print it lol.Should be easy enough to add some css like ``` media print { #page-nav { display: none !important; } } ``` to the end of style.css in your generated docs folder then refresh it in your browser. Can add other things to hide there too if you want.That solved that, thanks. Lastly then, is there any CSS wizardry to be used to make it word-wrap? The final hurdle is that it's cutting off text, like in https://i.imgur.com/fWCVdYn.png. Looking at it in a browser and shrinking the window, I guess maybe it doesn't wrap to begin with.
Mar 16
On Sunday, 16 March 2025 at 17:50:44 UTC, Anonymouse wrote:Lastly then, is there any CSS wizardry to be used to make it word-wrap?Yeah, I specifically disabled word wrap for code blocks because I prefer horizontal scrolling them in a browser. Add this either to that same media print block, or right under it (if you want it to affect in the browser too) and you should get OK results: ``` pre { white-space: pre-wrap !important; } ``` This tells it to use the pre-formatted whitespace, but allow wrapping as needed, with important there to override any previous commands.
Mar 16
On Sunday, 16 March 2025 at 18:02:54 UTC, Adam D. Ruppe wrote:On Sunday, 16 March 2025 at 17:50:44 UTC, Anonymouse wrote:The wrapping [looks a bit funky](https://i.imgur.com/aYQT5Tc.png) but I think I can work with this. Thanks!Lastly then, is there any CSS wizardry to be used to make it word-wrap?Yeah, I specifically disabled word wrap for code blocks because I prefer horizontal scrolling them in a browser. Add this either to that same media print block, or right under it (if you want it to affect in the browser too) and you should get OK results: ``` pre { white-space: pre-wrap !important; } ``` This tells it to use the pre-formatted whitespace, but allow wrapping as needed, with important there to override any previous commands.
Mar 16
On Sunday, 16 March 2025 at 16:26:55 UTC, Anonymouse wrote:I want to generate PDFs of the individual source files of my project. Preferably with syntax highlighting, but if pressed I could live without it for this particular case. I would like line numbers though. HTML is fine too as I could just print them to PDF. `dub build -b docs` and `ddox` and `adrdox` etc can all generate API summary documentation, but I have a need for the source files themselves. So far the best I've managed is to browse to the pages for the source files on GitHub and print those to PDF. It works, but you get the top of the page with the menu etc included, and it's put simply a pain to manually do when you have 75 source files. Is there any elegant solution I'm missing?`dub run dscanner -- --highlight source/app.d` or `highlight -o html -i source/app.d -o test.html` Andrea
Mar 17