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

Documentation for core.common #1510

Merged
merged 13 commits into from Jul 22, 2023
Merged

Documentation for core.common #1510

merged 13 commits into from Jul 22, 2023

Conversation

takase1121
Copy link
Member

Closes #1505.

@takase1121 takase1121 added this to In progress in Documentation via automation May 10, 2023
@jgmdev
Copy link
Member

jgmdev commented May 10, 2023

So far looking beautiful

@takase1121 takase1121 marked this pull request as ready for review May 10, 2023 13:35
Copy link
Member

@Guldoman Guldoman left a comment

Choose a reason for hiding this comment

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

I wonder if we should always use # before descriptions.
We need to put up an annotations style guide.

data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
takase1121 and others added 2 commits May 11, 2023 09:18
Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
the docs now follow the style in docs/ directory.
some of the changes suggested are also implemented.
@takase1121 takase1121 requested a review from Guldoman May 14, 2023 08:49
Copy link
Member

@Guldoman Guldoman left a comment

Choose a reason for hiding this comment

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

We really need guidelines for this.
For example it might be better to avoid adding the initial ---, as well as avoiding the space between params and returns. Or even standardize the use of # for descriptions.

data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
@takase1121
Copy link
Member Author

We really need guidelines for this. For example it might be better to avoid adding the initial ---, as well as avoiding the space between params and returns. Or even standardize the use of # for descriptions.

the leading dashes are from docs/. I'm following an existing style as guidelines.

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
@Guldoman
Copy link
Member

Yeah, I get that, but it might be a bit too verbose for in-source annotations.

jgmdev added a commit to pragtical/pragtical that referenced this pull request Jun 2, 2023
Extra whitespaces are removed and @overload is used whenever possible.
@takase1121
Copy link
Member Author

takase1121 commented Jul 21, 2023

I've updated the docs to fix some errors and rephrase some confusing parts.
I don't really have any solid guidelines, aside from a few points I followed when writing docs.

  1. The description is split into a brief and detailed descriptions. Each description generally has one or two sentences that explains what the function does. Sometimes some function can have extra stuffs, so I placed a linebreak and continue with more detailed explanations.
  2. All parameters have types. Avoid the use of any as much as possible. Descriptions are good when the parameter name is not self explanatory (e.g. the files parameter for fuzzy search, what does it do exactly?)
  3. If the function accepts multiple types of parameters and return different types of values based on the input, use @overload to properly document them. @overload does not allow you to add type-specific descriptions, so make sure that it is covered in @param or description.
  4. return types should always be documented. Return variable name is optional, but if you think it helps with readability then add it. Return descriptions are generally avoided (because they don't really look good in my opinion), but is used when the function returns something you wouldn't expect.
  5. Keep descriptions in @param, @field, @return short. For some reason LuaLs devs thinks that putting a newline in these descriptions will produce a linebreak, and for @field you'll have to put the multiline description before the @field annotation. It makes the doc look stupid unless you have LSP.

data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
@takase1121
Copy link
Member Author

I opted to make some parameters type|nil instead of making it optional, because they aren't supposed to be optional. For instance, common.merge allows both arguments to be nil, but it does not make sense to call them optional as it implies common.merge(). Instead, a should be table|nil which implies common.merge(nil) which is a more likely scenario.

@Guldoman
Copy link
Member

I opted to make some parameters type|nil instead of making it optional, because they aren't supposed to be optional.

Yeah I'm alright with that.

data/core/common.lua Outdated Show resolved Hide resolved
data/core/common.lua Outdated Show resolved Hide resolved
@Guldoman Guldoman merged commit 7b330ae into lite-xl:master Jul 22, 2023
10 checks passed
Documentation automation moved this from In progress to Done Jul 22, 2023
takase1121 added a commit to takase1121/lite-xl that referenced this pull request Aug 19, 2023
* docs(core.common): add and improve documentation

* refactor(core.common): remove unused variable to get_height()

* docs(core.common): remove messy newlines

* docs(core.common): fix wording

* docs(core.common): use integer instead of number

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): update docs

the docs now follow the style in docs/ directory.
some of the changes suggested are also implemented.

* docs(core.common): fix typo

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): restyle annoatations

Extra whitespaces are removed and @overload is used whenever possible.

* docs(core.common): fix various documentation errors

* docs(core.common): simplify unicode description

* docs(core.common): fix return value

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): clarify common.bench for not being a benchmark

* docs(common): add disclaimer for numbers in common.serialize

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
takase1121 added a commit to takase1121/lite-xl that referenced this pull request Aug 19, 2023
* docs(core.common): add and improve documentation

* refactor(core.common): remove unused variable to get_height()

* docs(core.common): remove messy newlines

* docs(core.common): fix wording

* docs(core.common): use integer instead of number

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): update docs

the docs now follow the style in docs/ directory.
some of the changes suggested are also implemented.

* docs(core.common): fix typo

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): restyle annoatations

Extra whitespaces are removed and @overload is used whenever possible.

* docs(core.common): fix various documentation errors

* docs(core.common): simplify unicode description

* docs(core.common): fix return value

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): clarify common.bench for not being a benchmark

* docs(common): add disclaimer for numbers in common.serialize

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
takase1121 added a commit to takase1121/lite-xl that referenced this pull request Aug 19, 2023
* docs(core.common): add and improve documentation

* refactor(core.common): remove unused variable to get_height()

* docs(core.common): remove messy newlines

* docs(core.common): fix wording

* docs(core.common): use integer instead of number

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): update docs

the docs now follow the style in docs/ directory.
some of the changes suggested are also implemented.

* docs(core.common): fix typo

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): restyle annoatations

Extra whitespaces are removed and @overload is used whenever possible.

* docs(core.common): fix various documentation errors

* docs(core.common): simplify unicode description

* docs(core.common): fix return value

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): clarify common.bench for not being a benchmark

* docs(common): add disclaimer for numbers in common.serialize

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Document core.common
3 participants