Is it possible to insert an image in a code comment?

My question is probably a crazy idea, however, it is very valuable when I write code for educational purposes.

Especially when the code refers to mathematics and physics, the images inserted into the commentary are more convenient and clearly formulated.

So far I canโ€™t find a way to insert the true image into the comment, not C #, nor python, nor any other common programming language or IDE.

Using tools that convert an image to an ASCII image is a workaround with less precision.

Any idea appreciated

+6
source share
5 answers

Here is an example that extends the Visual Studio 2010 editor: Inserting an image (but it is tied to Visual Studio, not to the general solution)

+5
source

Competent programming tools work this way; you mainly use TeX or something to write code, and then run the preprocessor, which extracts the pieces of code into the intermediate source file. http://en.wikipedia.org/wiki/Literate_programming

+1
source

Each SHFB project is its own container for everything that is visible in the draft documentation. When it is compiled, an XML document (software project) XML is inserted into the SHFB for placement in the document.

If you want to display images at the top of the class documentation, you must add the image to the SHFB project and refer to this image from the code comment. See Problem 2 ...

Problem 1:

"I cannot get an image to be displayed from a conceptual theme using the" image "tag

  • Be sure to use appropriate XML markup similar to this:

    <section> <content> <mediaLink> <image xlink:href="MyMainImage"/> </mediaLink> </content> </section> 
  • Please note that the HREF link (above) does not support the file type ,
    this is because Sandcastle wants an ID .

  • Add an image to the project using the default media folder . Or, if you want, you can create your own folder, for example, images.
  • Go to the image properties page and set the Build option to Image . When you use the "image" tag, SHFB only uses the Image Identifier found on the property page, as shown in the HREF above.
  • Recompile the project and open the CHM file and you will see the image.

Problem 2:

"I cannot get an image to be displayed using code commenting on XML markup in a programming project."

  • In the summary section of the code comment, the markup might look like this: this:

     /// <summary> /// <remarks><img src="\Images\MyImage.PNG"/></remarks> /// </summary> 
  • Note that the src attribute contains the containing file type. It must also correctly identify the folder that your SHFB project has for this image.

  • After adding this image to SHFB, right-click on it and change the "Create Action" property to Content

Happy coding and documentation! Thanks Eric W.

Keywords: SHFB cannot add image Sandcaple Help File Builder Conceptual image themes Image comment code images CHM file images How to add image to XML code Commenting C #

+1
source

I think you are using the wrong tool for your problem. The IDE is a development environment, so itโ€™s not very important to have full control over the styles.

I would use something else (e.g. LaTeX, see comment) for presentation.

0
source

Why not use a free image hosting service like http://imgur.com and insert a link to the code comment?

Then the only problem for the student would be to copy the link to the browser link from any IDE. Pretty easy.

Perhaps some IDEs have the ability to "underline" links so that you can click on it instead of copypasting.

0
source

Source: https://habr.com/ru/post/895722/


All Articles