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: use same parameter names as in doc string #481

Merged

Conversation

rrrnld
Copy link

@rrrnld rrrnld commented Jul 14, 2024

I realized that there is a naming mismatch in the text mismatch when looking at the docs for the polar / cartesian conversion fns: https://docs.thi.ng/umbrella/vectors/functions/cartesian.html.

I changed the references in the source code, but still saw the docs using cartesian(out, a, b?) as the function signature after generating the docs locally. I ran the following commands to regenerate the docs:

yarn clean
yarn build
yarn doc:ae
yarn doc

Is there anything else to do? I didn't find anything with rg -i 'cartesian.*?out.*?a.*?b'.

If this is a bug in typedoc I may also go the other way around and rename the function params to a and b.

@postspectacular
Copy link
Member

@heyarne — yeah it's one of (many) TypeDoc issues, here specifically that TypeDoc ignores @param doc tags entirely in cases like this. The entire docs of the vectors package suffer from that and have been the source of much frustration, not just for users, also for myself trying to find a better solution. Some related issues (with compounding effects):

  • TypeDoc (TD) is treating arrow functions as 2nd/3rd class citizens
  • When using higher-order function and/or type aliases to type hint functions, it only uses the doc information (e.g. arg names) assigned to that type alias, ignoring any docstring attached in-situ.

For example, the maddN() docs completely skip/ignore the doc string which is actually present in the source.

Similar situation for most functions in the maths package, which are mostly typed using the handy FnN family of re-usable types for numeric functions. E.g. The clamp() docs at least show parts of the doc string, but the arg/param names are not the ones used in the clamp docs, but the generic ones (a, b, c) assigned to FnN3, which is the type alias used for hinting that function...

/**
* Clamps value `x` to given closed interval.
*
* @param x - value to clamp
* @param min - lower bound
* @param max - upper bound
*/
export const clamp: FnN3 = (x, min, max) => (x < min ? min : x > max ? max : x);

The only solution here would be to stop using function types altogether and then rewriting all the thousands of function headers... but I don't think that's right, and also a doc tool should not have such a major (negative) impact to force a code style, which must ignore some very useful core language features, only because the tool doesn't support them properly...

Btw. The same issue has come up several times and I do know it needs a solution, but I just don't have the energy/time to solve this. I'm grateful for any ideas though...

@postspectacular postspectacular merged commit 70460a3 into thi-ng:develop Jul 16, 2024
1 check passed
@postspectacular
Copy link
Member

In any way, thank you for this PR @heyarne! Even if TypeDoc doesn't play ball, it's improving legibility!

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.

2 participants