Skip to content

(cds 9) Propagation of doc comments #1825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions cds/cdl.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,6 @@ entity Employees {
The text of a doc comment is stored in CSN in the property `doc`.
When generating OData EDM(X), it appears as value for the annotation `@Core.Description`.

When generating output for deployment to SAP HANA, the first paragraph of a doc comment is translated to the HANA `COMMENT` feature for tables, table columns, and for views (but not for view columns):

```sql
CREATE TABLE Employees (
ID INTEGER,
name NVARCHAR(...) COMMENT 'I am the description for "name"'
) COMMENT 'I am the description for "Employee"'
```

::: tip
Propagation of doc comments can be stopped via an empty one: `/** */`.
:::

In CAP Node.js, doc comments need to be switched on when calling the compiler:

::: code-group
Expand All @@ -331,13 +318,41 @@ cds.compile(..., { docs: true })

:::

::: tip Doc comments are enabled by default in CAP Java.
In CAP Java, doc comments are automatically enabled by the [CDS Maven Plugin](../java/developing-applications/building#cds-maven-plugin). In generated interfaces they are [converted to corresponding Javadoc comments](../java/assets/cds-maven-plugin-site/generate-mojo.html#documentation).
::: tip Doc comments are automatically enabled in CAP Java.
In CAP Java, doc comments are automatically enabled by the [CDS Maven Plugin](../java/developing-applications/building#cds-maven-plugin).
In generated interfaces they are [converted to corresponding Javadoc comments](../java/assets/cds-maven-plugin-site/generate-mojo.html#documentation).
:::


Doc comments are not propagated by default. For example, a doc comment defined for an entity
isn't automatically copied to projections of this entity. Propagation can be switched on:

__TODO__ verify option name

::: code-group

```sh [CLI]
cds compile foo.cds --docs --propagate-docs
```

```js [JavaScript]
cds.compile(..., { docs: true, propagateDocs: true })
```

:::

When switched on, propagation of doc comments can selectively be stopped via an empty one: `/** */`.


When generating output for deployment to SAP HANA, the first paragraph of a doc comment is translated
to the HANA `COMMENT` feature for tables, table columns, and for views (but not for view columns):

```sql
CREATE TABLE Employees (
ID INTEGER,
name NVARCHAR(...) COMMENT 'I am the description for "name"'
) COMMENT 'I am the description for "Employee"'
```


## Entities & Type Definitions
Expand Down