VS Code Syntax Highlighting for AIMMS Text Representation

  • 30 July 2019
  • 6 replies
  • 375 views

Userlevel 4
Badge
  • AIMMS Implementation Partner
  • 57 replies
Is there an extension or language config so I can view my AIMMS Text Representation with syntax highlighting in VS Code?

It would be super helpful.

I think I can create one, but if someone's already invented that wheel, no sense in re-inventing it.

Thanks, y'all!

~Bon

6 replies

Userlevel 4
Badge +1
Hey @MathFour,

It's really interesting that you are asking about it now !

We developed a syntax highlighting in Python, using the Pygments package and a set of regular expression rules. This syntax highlighting is notably used in our documentation (https://how-to.aimms.com/ and https://documentation.aimms.com/) to highlight code blocks.

Since you asked about it, I chose to create an open source repo containing it. The styling attached file is published as well. We have the project to make it part of Pygments supported languages, at some point :)

I'm not sure if you can use it directly in VS code, but you may take a look at the set of regex rules, It will definitely help you build another one if needed :)

Looking forward your feedback !

Hi @MathFour, I was looking for this highlight syntax and I found this topic, did you make this tool?  if so, could you share?

thanks!

 

Userlevel 4
Badge

@patrickvasconcelos - Arthur has it linked.

Userlevel 2
Badge +3

@Arthur, thanks for making the relevant python modules for sphinx documentation public!

Is there a recommended way to structure the comment attribute of a function/procedure to convert from AMS to RST correctly for documentation? I cannot quite match AIMMS Online Function Reference style.

I tried the formatting style in AimmsXLLibrary (for example, axll::ReadList) and ended up with a HTML page as in attached/inserted image. Is it that parsing and conversion of comment attribute to appropriate RST not supported?

Thanks!

 

Userlevel 4
Badge +1

Hi @Sree , 

Thanks or your feedback!

I am working on a script that is converting AMS files to RST 

https://gitlab.com/ArthurdHerbemont/conversion-aimms-ams2rst

 

Using the script, your comments in AIMMS should be written in RST syntax.

Comments in the AIMMSXLLibrary are not yet written in RST syntax (we are working on it, as you can see here). The expected result is shown below:

https://arthurdherbemont.gitlab.io/aimmsxllibrary-docs-staging/

It is just an example of how you can write your comments. Many other options are available as described here for example

The script will treat other attributes (like Range, or IndexDomain for example) as sphinx function attributes. 

 

However, of course you have the freedom to use it the way you want. You may write:

.. :aimms:procedure:: MyProcedure

:attribute Property: UndoSafe
:attribute Comment: This is a comment to explain things

 As described in the AIMMS Domain docs

Instead of:

.. :aimms:procedure:: MyProcedure

:attribute Property: UndoSafe

This is a comment to explain things

Is that answering your question ? Could you maybe share your project files ?

Userlevel 2
Badge +3

@Arthur, that answers my question. I will structure my comments in RST format.

I did use your convert AMS2RST project. (I had to modify it a little for Python 3 support and add UnitParameter support in AIMMSLexer and AIMMSDomain.)

Unfortunately, I don't have a GitHub/GitLab account at work to fork these repos and have the projects I am using to test them be public. But if I encounter any issues or find any interesting use cases, I will make an AIMMS project that I can share publicly and share it with you.

Thanks!

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator