Immediate-Mode-UI / Immediate-Mode-UI/Nuklear

NK_DTOA needs more documentation

Open
#699 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.4k
Forks
686
Avg merge
4d 1h
Merged PRs (30d)
3

Description

The current documentation states:

> You can define this to dtoa or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).

The problem is, there is no such function. `dtoa` is neither in C standard library, C++ standard library or in POSIX. I just don't know what is the "contract" of this function.

Based on Nuklear's code:

https://github.com/Immediate-Mode-UI/Nuklear/blob/ca8aaf3f65e9fc8ac5d90fefc1204585add4b89b/nuklear.h#L7116-L7117

The function takes a buffer and a value of type `double` and returns the end of the string in the buffer.

*How large the buffer should be?* I checked the implementation and found out it is `NK_MAX_NUMBER_BUFFER`. This constant is documented but it is easy to lose it - NK_DTOA does not mention it and does not even specify how the function should look like (and there is no standard function to look into).

IMO it should be documented that:
- `NK_DTOA` relies on `NK_MAX_NUMBER_BUFFER`
- what the expected function prototype is
- what the expected behavior is (e.g. returns start or end of buffer)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in nuklear.h at the NK_DTOA implementation around lines 7116-7117, then compare it with the existing NK_MAX_NUMBER_BUFFER documentation. Document the expected function prototype, buffer-size relationship, and whether the return value points to the start or end of the generated string.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.