Skip to content
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

docs: Add multi-language entrypoint function page #7351

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

vikram-dagger
Copy link
Contributor

No description provided.

@vikram-dagger
Copy link
Contributor Author

Noting that in this case, the original constructor pages for TypeScript and Python have been split, with the first common section extracted to a multi-language page and the remainder left as language-specific content. @helderco and @TomChv please review this to confirm nothing has been lost in translation.

Copy link
Contributor

@kpenfound kpenfound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense!

@TomChv
Copy link
Member

TomChv commented May 14, 2024

Hey! Thanks for the changes I'm going to review this tomorrow! 👀

@vikram-dagger vikram-dagger force-pushed the docs-243-constructor branch 2 times, most recently from fffc5ca to 8ff0552 Compare May 14, 2024 13:50
@helderco
Copy link
Contributor

Note to use latest dagger version to update the output of --help since there's been some changes there. Flags, for example, have been renamed to Options, but specifically in the case of dagger call, they show as Arguments.

More context in:

:::note
If you plan to use constructor fields in other module functions, ensure that they are declared as public. This is because Dagger stores fields using JSON marshalling and private fields are omitted during the marshalling process. As a result, if a field is not declared as public, calling methods that use it will produce unexpected results.
:::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"declared as public" isn't a thing in Python.

"Marshalling" is a term usually seen in Go. Can use the more general terms "serialization" and "deserialization" (no need for mentioning JSON too).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified

Comment on lines 10 to 12
:::info
This language-specific page should be read together with the main [module constructor documentation](../constructor.mdx).
:::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should evolve into one page per SDK for more details on various topics, including this one.

It's not necessaritly that this page needs to be read together with the common one if we can make the common section like a sort of basics, and the language-specific more like advanced/detailed information.

In that sense, I think it's ok to have some SDK specific information inside an SDK tab, if it helps to cover the "basics". Even better if we can use collapsed admonitions, like this:

Screenshot 2024-05-13 at 15 11 32

Generally speaking, collapsed admonitions would help keep the content lighter, while still providing additional (and optional) information without having to link to another page in a lot of cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the moment I have removed this note. I would like to separately discuss the topic of a single language-specific page vs a language category. Briefly, for me, the latter has two advantages:

  • avoids overloading too much content on one page (eg. this Python-specific constructor page already has a lot of information)
  • makes it more visible, as each language-specific page will have a separate sidebar entry

```

:::note
Dagger modules have only one constructor. Constructors of custom types are not registered; they are constructed by the function that [chains](./chaining.mdx) them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the link to custom types, I assume because that doc merge hasn't been merged yet. But it's already been approved so making a note to not forget adding it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added


The code listing above is an example of an object that has typed attributes.

[Learn more about Python module constructors](./python/constructor.mdx).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link looks a bit off in the middle of the text here:

Screenshot 2024-05-15 at 12 52 02

Could use a visual break, if not a section break (no one that makes sense here) maybe an arrow/emoji, or in an admnonition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to end of page

```python file=./snippets/constructor/python/main.py
```

In the Python SDK, the [`@dagger.object_type`](https://dagger-io.readthedocs.io/en/latest/module.html#dagger.object_type) decorator wraps [`@dataclasses.dataclass`](https://docs.python.org/3/library/dataclasses.html), which means that an `__init__()` method is automatically generated, with parameters that match the declared class attributes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better in an info admonition. It's important to know that @object_type is a @dataclass. Perhaps even put the "learn more" link here as most of that is about the dataclass thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to admonition. Link is added at the end of the page

docs/current_docs/manuals/developer/python/constructor.mdx Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In "Asynchronous constructor", maybe embolden:

a factory class method which must be named create:

It's important to know it has to have that name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to highlight box

@vikram-dagger
Copy link
Contributor Author

Note to use latest dagger version to update the output of --help since there's been some changes there.

Updated. Can you please review again @helderco ? Thank you!

@levlaz
Copy link
Contributor

levlaz commented May 24, 2024

Vikram and I looked this, once links are removed and bottom note is combined I think this is ready to ship.

@vikram-dagger vikram-dagger force-pushed the docs-243-constructor branch 2 times, most recently from 856fc66 to 71131e8 Compare May 25, 2024 06:52
@vikram-dagger
Copy link
Contributor Author

vikram-dagger commented May 25, 2024

Noting here that the language-specific constructor pages have very different examples. These have been merged into this page under separate headings. I'm not sure if these are different because of actual disparity between SDKs or because they were authored at different times. See the preview at https://deploy-preview-7351--devel-docs-dagger-io.netlify.app/manuals/developer/constructor/

I would like @helderco @TomChv @kpenfound to review this once and advise which of the language-specific examples could be made multi-language. I'm not sure if we need to block merging this PR until the above is reviewed and new examples possibly created by the SDK maintainers. WDYT @helderco @levlaz @jpadams @kpenfound ?

@shykes
Copy link
Contributor

shykes commented May 25, 2024

Can I also request that we call this topic "entrypoint functions" and explain that every module has one. The default one is generated automatically and has no arguments; It's possible to write a custom entrypoint function, the mechanism is SDK-specific.

@vikram-dagger
Copy link
Contributor Author

Can I also request that we call this topic "entrypoint functions" and explain that every module has one. The default one is generated automatically and has no arguments; It's possible to write a custom entrypoint function, the mechanism is SDK-specific.

Done, let me know if further changes needed. I made this change in the title, intro and first section but not in the following language-specific ones since the constructor mechanism has been explained by that point.

Signed-off-by: Vikram Vaswani <vikram@dagger.io>
This reverts commit dff4791.

Signed-off-by: Vikram Vaswani <vikram@dagger.io>
This reverts commit 2f27465.

Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
Hello, Daggerverse!
```

Constructor arguments are documented through their attribute documentation,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This inline doc section is not transferred because there is a similar example (object documentation) already provided in the inline documentation page, but lmk if this is not correct @helderco

@vikram-dagger vikram-dagger changed the title docs: Add multi-language constructor page docs: Add multi-language entrypoint function page May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants