Is there a way to embed <script> content into a Doxygen \mainpage section?
Asked Answered
G

1

5

I would like to introduce some javascript <script>xxx</script> content into my generated index.html in order to add reddit and facebook "like" buttons to my project's main page. Is there a way to accomplish this automatically using Doxygen?

Thanks,

SetJmp

Galibi answered 6/9, 2011 at 5:57 Comment(0)
P
6

You can use @mainpage in combination with an @htmlonly...@endhtmlonly block. Here is an example:

/** @mainpage My Script Page

Here is an embedded script:
@htmlonly
 <script type="text/javascript">
 function displayDate()
 {
 document.getElementById("demo").innerHTML=Date();
 }
 </script>
 <div id="demo">date</div>
 <script type="text/javascript">displayDate();</script>
 <br/>
 <button type="button" onclick="displayDate()">Refresh Date</button>
@endhtmlonly

*/
Potage answered 6/9, 2011 at 18:33 Comment(4)
Although this answer passed a few days i just want to mention that the documentation generated could probably contain C++ like comments starting with //! which prevents this script from being interpreted if the code placed in between the htmlonly tags is a block sequence. Then one should use the htmlonly tag followed by a one liner containing the block to be evaluated/displayed.Clabber
@EmilKakkau I don't understand what you are trying to say. //! comments inside a \htmlonly block should be copied to the output without interpretation.Potage
in my doc building szenario (bash+doxygen) the <script>-tag was embedded into the html code as i expected it to do. BUT all the code in between the htmlonly instruction was prefixed by //! in the generated html (output) file so the execution of the script tag was not invoked. if you need an example i will post an answer to illustrate.Clabber
or just have a look at my answer at #1603432. in the documentation code i was just able to use a single line to make the <script>-tag between the htmlonly instruction work in the genereted html.Clabber

© 2022 - 2024 — McMap. All rights reserved.