# Gnatdoc and generic package parameters

**URL:** https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447
**Category:** General
**Created:** [July 26, 2023, 8:56am UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447 "2023-07-26T08:56:08Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![cantanima](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/cantanima/32/121_2.png) [@cantanima](https://forum.ada-lang.io/u/cantanima)
#### Post date: [July 26, 2023, 8:56am UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/1 "2023-07-26T08:56:08Z")

</div>

`gnatdoc` doesn’t seem to document generic parameters to a package. Does that sound right?

In case my meaning isn’t clear, the following specification should do the trick. Ask away if not.

```ada
-- @summary this commentary appears (as long as there's no space between it and "generic" keyword)
generic
   type T is <>;
   -- commentary on T does not appear
   function "=" ( Left, Right: T ) return Boolean is <>;
   -- commentary on "=" does not appear
package P is
   -- commentary in here appears

```

---

<div class="post-metadata">

### Author: ![jere](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/jere/32/87_2.png) [@jere](https://forum.ada-lang.io/u/jere)
#### Post date: [July 26, 2023, 2:43pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/2 "2023-07-26T14:43:04Z")

</div>

For kicks, try spacing it out more:

```ada
-- @summary this commentary appears (as long as there's no space between it and "generic" keyword)
generic 

   type T is <>;
   -- commentary on T does not appear

   function "=" ( Left, Right: T ) return Boolean is <>;
   -- commentary on "=" does not appear

package P is
   -- commentary in here appears

```

I don’t use gnatdoc anymore, but in the distant past having everything clumped together got it confused (I’m hoping that is no longer an issue these days).

---

<div class="post-metadata">

### Author: ![cantanima](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/cantanima/32/121_2.png) [@cantanima](https://forum.ada-lang.io/u/cantanima)
#### Post date: [July 26, 2023, 3:06pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/3 "2023-07-26T15:06:53Z")

</div>

The formatting is artificial to the original post. In my file, I ran the GNAT Studio code editor formatter. The spacing is there. Your suggestion is how I format my files normally, anyway.

I eventually got something sort-of acceptable by adding a custom `@generics` tag and placing that along with the documentation of the generic parameters in the package description, but that leaves a lot to be desired. My incompetence at creating a custom tag isn’t helping.

---

<div class="post-metadata">

### Author: ![jere](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/jere/32/87_2.png) [@jere](https://forum.ada-lang.io/u/jere)
#### Post date: [July 26, 2023, 7:27pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/4 "2023-07-26T19:27:45Z")

</div>

My apologies then. I was not trying to be artificial.

---

<div class="post-metadata">

### Author: ![cantanima](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/cantanima/32/121_2.png) [@cantanima](https://forum.ada-lang.io/u/cantanima)
#### Post date: [July 27, 2023, 4:38am UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/5 "2023-07-27T04:38:36Z")

</div>

I think you misunderstood. I meant that _my_ original post’s example was aritificial, and so the formatting was likewise artificial. I usually format things the same way you did.

---

<div class="post-metadata">

### Author: ![godunko](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/godunko/32/22_2.png) [@godunko](https://forum.ada-lang.io/u/godunko)
#### Post date: [July 27, 2023, 5:46pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/6 "2023-07-27T17:46:53Z")

</div>

You code snippet is not valid Ada code, thus GNATdoc can’t process it.

Also note, there are two versions of GNATdoc. Old one has known limitations on processing many constructs. New one is based on LAL, it is able to process almost all constructs, however it doesn’t support all features of old version on GNATdoc (like @summary tag). New version is used by ALS to create descriptions of the entities in tooltips.

If you observe any issues with entities description created by recent version of ALS, you can create ticket on GitHub.

---

<div class="post-metadata">

### Author: ![cantanima](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/cantanima/32/121_2.png) [@cantanima](https://forum.ada-lang.io/u/cantanima)
#### Post date: [July 27, 2023, 6:05pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/7 "2023-07-27T18:05:24Z")

</div>

Sorry, what’s invalid? Keep in mind that it was an example, an excerpt off the top of my head, to illustrate the basic idea. It wasn’t meant to be fully fleshed-out code.

If you want to see the code I was actually struggling to get `gnatdoc` to document, you can find it [here](https://github.com/johnperry-math/euclidean/blob/b835bb16fcaf4f7a991b78699296826f4c246936/src/euclidean.ads).

---

<div class="post-metadata">

### Author: ![krischik](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/krischik/32/420_2.png) [@krischik](https://forum.ada-lang.io/u/krischik)
#### Post date: [December 26, 2024, 5:43pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/8 "2024-12-26T17:43:19Z")

</div>

> [@cantanima](#):
>
> I eventually got something sort-of acceptable by adding a custom `@generics` tag

How did you do that?

> [@godunko](#):
>
> Also note, there are two versions of GNATdoc.

Can you use the new version with Alire? And if so: how?

---

<div class="post-metadata">

### Author: ![cantanima](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/cantanima/32/121_2.png) [@cantanima](https://forum.ada-lang.io/u/cantanima)
#### Post date: [December 27, 2024, 6:13am UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/9 "2024-12-27T06:13:29Z")

</div>

> [@krischik](#):
>
> > [@cantanima](#):
> >
> > I eventually got something sort-of acceptable by adding a custom `@generics` tag
> 
> How did you do that?

Gnatdoc is extensible via Python. You can find the code that worked [at this link](https://github.com/johnperry-math/euclidean/blob/b835bb16fcaf4f7a991b78699296826f4c246936/more_tags.py). You’ll want to look at the usage [here](https://github.com/johnperry-math/euclidean/blob/b835bb16fcaf4f7a991b78699296826f4c246936/src/euclidean.ads).

I had plumb forgotten about this, so I’m not sure I can provide more guidance than that.

---

<div class="post-metadata">

### Author: ![godunko](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/godunko/32/22_2.png) [@godunko](https://forum.ada-lang.io/u/godunko)
#### Post date: [December 30, 2024, 10:43am UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/10 "2024-12-30T10:43:55Z")

</div>

I suppose new GNATdoc is available in Alire.

---

<div class="post-metadata">

### Author: ![krischik](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/krischik/32/420_2.png) [@krischik](https://forum.ada-lang.io/u/krischik)
#### Post date: [December 30, 2024, 2:36pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/11 "2024-12-30T14:36:07Z")

</div>

I wasn’t able to make gnatdoc work with only Alire. Currently I use `alr exec -P1 -- gnatpp` with `gnatpp` coming from **GNATStudio.app** which @simonjwright provided.

This is of course a kludge. Hence my question.

---

<div class="post-metadata">

### Author: ![OneWingedShark](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/onewingedshark/32/305_2.png) [@OneWingedShark](https://forum.ada-lang.io/u/OneWingedShark)
#### Post date: [December 30, 2024, 2:53pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/12 "2024-12-30T14:53:48Z")

</div>

> [@cantanima](#):
>
> Sorry, what’s invalid?

> [@cantanima](#):
>
> ` type T is <>;`

The above isn’t a valid formal parameter specification; though it would be with `(<>)`.

---

<div class="post-metadata">

### Author: ![simonjwright](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/simonjwright/32/11_2.png) [@simonjwright](https://forum.ada-lang.io/u/simonjwright)
#### Post date: [December 30, 2024, 6:34pm UTC](https://forum.ada-lang.io/t/gnatdoc-and-generic-package-parameters/447/13 "2024-12-30T18:34:50Z")

</div>

> [@krischik](#):
>
> `gnatpp` coming from **GNATStudio.app** which @simonjwright provided.

Not me, that was Blady at Sourceforge
