Back to Dagger

Inline Documentation

docs/current_docs/extending/modules/documentation.mdx

0.20.73.6 KB
Original Source

Inline Documentation

Dagger modules and Dagger Functions should be documented so that descriptions are shown in the API and the CLI - for example, when calling dagger functions, dagger call ... --help, or .help.

<Tabs groupId="language" queryString="sdk"> <TabItem value="go" label="Go">

The following code snippet shows how to add documentation for:

  • The whole module
  • Function methods
  • Function arguments
go
</TabItem> <TabItem value="python" label="Python">

The following code snippet shows how to use Python's documentation string conventions for adding descriptions to:

  • The whole module or package
  • Object type classes (group of functions)
  • Function methods
  • Function arguments

For function arguments, annotate with the dagger.Doc metadata.

:::note dagger.Doc is just an alias for typing_extensions.Doc. :::

python
</TabItem> <TabItem value="typescript" label="TypeScript">

The following code snippet shows how to add documentation for:

  • The whole module
  • Function methods
  • Function arguments
typescript
</TabItem> <TabItem value="php" label="PHP">

The following code snippet shows how to add documentation for:

  • The whole module
  • Function methods
  • Function arguments
php
</TabItem> <TabItem value="java" label="Java">

The following code snippet shows how to add documentation for:

  • Function methods
  • Function arguments
java

The documentation of the module is added in the package-info.java file.

java
/**
 * A simple example module to say hello.
 *
 * Further documentation for the module here.
 */
@Module
package io.dagger.modules.mymodule;

import io.dagger.module.annotation.Module;

</TabItem> </Tabs>

Here is an example of the result from dagger functions:

Name         Description
hello        Return a greeting.
loud-hello   Return a loud greeting.

Here is an example of the result from dagger call hello --help:

Return a greeting.

USAGE
  dagger call hello [arguments]

ARGUMENTS
      --greeting string   The greeting to display [required]
      --name string       Who to greet [required]

The following code snippet shows how to add documentation for an object and its fields in your Dagger module:

<Tabs groupId="language" queryString="sdk"> <TabItem value="go" label="Go">
go
</TabItem> <TabItem value="python" label="Python">
python
</TabItem> <TabItem value="typescript" label="TypeScript">
typescript
</TabItem> <TabItem value="php" label="PHP">
php
</TabItem> <TabItem value="java" label="Java">
java
</TabItem> </Tabs>

Here is an example of the result from dagger call --help:

ARGUMENTS
      --age int       The age of the user. [required]
      --name string   The name of the user. [required]