Website: Show random empty function

This commit is contained in:
Johannes Kirschbauer 2024-10-24 22:49:31 +02:00
parent 069604f203
commit 5bdcec2bc8
No known key found for this signature in database
2 changed files with 15 additions and 24 deletions

View File

@ -4,12 +4,11 @@ Writing good documentation is hard. Any contribution towards having a better doc
## Doc-comments
Doc-comments, short for documentation comments, are special comments in source code that are specifically formatted to provide documentation for the
associated code.
These comments serve as a source of reference documentation for noogle,
offering valuable information about the purpose, functionality, and usage of the code elements they document.
Doc-comments, short for documentation comments, are special comments in source code that are specifically formatted to provide documentation for the
associated code.
These comments serve as a source of reference documentation for noogle,
offering valuable information about the purpose, functionality, and usage of the code elements they document.
## Placement
@ -28,19 +27,4 @@ In any case you can place the documentation directly before the lamba. (only whi
x: x;
```
> **Advice**
>
> Open up the file in your editor and go to the exact `line` `column` marker that noogle gave you.
## Checklist for writing good documentation
- [ ] Describe what the function does.
- [ ] Provide examples for different scenarios when this function might be useful. -> ` # Example(s) `
- [ ] Provide a (single) type signature -> `# Type `
- [ ] What types does the function expect?
- [ ] Try to use this [typing convention](/md/typing) for best compatibility with noogle
- [ ] Describe the purpose of all arguments.-> `# Arguments`
- [ ] Positional Arguments
- [ ] All known Attributes
- [ ] Maybe describe edge cases or what else should be taken into account
- [ ] References to other functions
**For contributing to [nixpkgs]() check their documentation [contributing guide](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md)**

View File

@ -14,7 +14,10 @@ import { Preview } from "../preview/preview";
import { Doc, data as raw } from "@/models/data";
// Show only functions with content.
const data = raw.filter((d) => d.content?.content);
const data = raw;
const emptyIdxs = raw
.map((d, idx) => (d.content?.content ? false : idx))
.filter(Boolean);
const date = new Date();
@ -77,7 +80,11 @@ export const FunctionOfTheDay = () => {
};
const setRandom = () => {
setIdx(getRandomIntInclusive(0, data.length - 1, { init: Math.random() }));
const random = getRandomIntInclusive(0, emptyIdxs.length - 1, {
init: Math.random(),
});
setIdx(emptyIdxs[random]);
};
const setFunctionOfTheDay = () => {
setIdx(todaysIdx);
@ -112,7 +119,7 @@ export const FunctionOfTheDay = () => {
</Button>
<Divider flexItem orientation="vertical" />
<Button sx={{ width: "100%" }} onClick={() => setRandom()}>
Random
Random Undocumented
</Button>
<Button sx={{ width: "100%" }} onClick={() => setFunctionOfTheDay()}>
Todays function