website icon indicating copy to clipboard operation
website copied to clipboard

Controls' properties' types should be given in the documentation.

Open taaaf11 opened this issue 2 years ago • 15 comments

It would be easier if types of properties are also given in the documentation.

Perhaps like this:

value: str The text displayed.

(From the Text documentation page.)

taaaf11 avatar Jun 23 '24 12:06 taaaf11

You can actually help with that, if you want :) Here's an example: https://flet.dev/docs/controls/image#fit

ndonkoHenri avatar Jun 23 '24 22:06 ndonkoHenri

Thank you!

taaaf11 avatar Jun 23 '24 23:06 taaaf11

Should the changes be like bool or Optional[bool] where it is optional?

taaaf11 avatar Jun 23 '24 23:06 taaaf11

(Almost) all properties are actually optional, so let's just mention the main type: bool

If you are hopping on this, please make sure to follow the style used "Value is of type ... [and defaults to ...]" :)

ndonkoHenri avatar Jun 23 '24 23:06 ndonkoHenri

Bruh, I have a question. Can I just "copy/paste" the values from function (property) definitions and see the def_value from there or is there something more to do, like with the action_button_padding with type of PaddingValue which is of course a union.

taaaf11 avatar Jun 24 '24 09:06 taaaf11

def_value is the default value of a property. Not all props have one though. But if the property you are willing to document has one, then you can mention it.

Concerning stuffs like PaddingValue, I think you can just write it like that in the docs too. We could then add a section/page in the docs (still thinking of how it could be named) for all of these types, with more information on the possible values.

ndonkoHenri avatar Jun 24 '24 13:06 ndonkoHenri

Got it!

As many of the PaddingValue things are also in the docs, I suggest the name of the section as "Type Aliases". This is also a name of a new feature in python.

taaaf11 avatar Jun 24 '24 14:06 taaaf11

Now there are conflicting types, there is a PaddingValue and a padding.Padding. I think I should leave those properties in the docs as they are in which type is given padding.Padding. They accept PaddingValue. What do you think?

taaaf11 avatar Jun 24 '24 14:06 taaaf11

I suggest the name of the section as "Type Aliases". This is also a name of a new feature in python.

Nice suggestion, thanks. So, we could have "Aliases" page under "References/Types" section of the docs. Will you like to create the file for this? (aliases.md under docs/references/types)

Now there are conflicting types, there is a PaddingValue and a padding.Padding.

If we have this aliases page, we could then set the value-type of all padding-related props to PaddingValue, which has link to the aliases page (it will look like /docs/references/types/aliases#paddingvalue).

This will fix the conflict, right?

ndonkoHenri avatar Jun 24 '24 17:06 ndonkoHenri

Will you like to create the file for this?

Sure!

taaaf11 avatar Jun 25 '24 00:06 taaaf11

A quick question @ndonkoHenri

~~Should it look like this~~

~~### PaddingValue~~

~~Union of int, float, Padding and None.~~

I have sent a pull request in exactly this format.

taaaf11 avatar Jun 25 '24 00:06 taaaf11

Can we close this issue as completed @taaaf11 ?

ndonkoHenri avatar Jul 18 '24 11:07 ndonkoHenri

For now, the laptop on which I write this code is not in working condition, and I don't know how much I would have to wait for that. As this issue is related to all controls, I think it should be kept opened. What is your opinion?

taaaf11 avatar Jul 18 '24 12:07 taaaf11

Alright, no prob, let's keep it opened.

ndonkoHenri avatar Jul 18 '24 21:07 ndonkoHenri

New website: https://docs.flet.dev/

ndonkoHenri avatar Jan 18 '26 12:01 ndonkoHenri