Skip to content

Commit

Permalink
chore: add --doc to test task and correct JSDocs (denoland#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua authored Sep 4, 2023
1 parent 6007bd4 commit 0623833
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 33 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"db:seed": "deno run --allow-read --allow-env --allow-net --unstable tools/seed_submissions.ts",
"db:reset": "deno run --allow-read --allow-env --unstable tools/reset_kv.ts",
"start": "deno run --unstable -A --watch=static/,routes/ dev.ts",
"test": "KV_PATH=:memory: deno test -A --unstable --parallel --coverage=./cov",
"test": "KV_PATH=:memory: deno test -A --unstable --parallel --coverage=./cov --doc",
"check:license": "deno run --allow-read --allow-write tools/check_license.ts",
"check:types": "deno check **/*.ts && deno check **/*.tsx",
"ok": "deno fmt --check && deno lint && deno task check:license --check && deno task check:types && deno task test",
Expand Down
10 changes: 0 additions & 10 deletions plugins/protected_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import { ensureSignedIn, type State } from "@/middleware/session.ts";
* {@linkcode handleNotSignedInRest}, if the request is made to a REST API
* endpoint.
*
* @example
* ```ts
* import { FreshOptions } from "$fresh/server.ts";
* import protectedRoutes from "@/plugins/protected_routes.ts";
*
* const options: FreshOptions = {
* plugins: [protectedRoutes]
* }
* ```
*
* @see {@link https://fresh.deno.dev/docs/concepts/plugins|Plugins documentation}
* for more information on Fresh's plugin functionality.
*/
Expand Down
37 changes: 16 additions & 21 deletions utils/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,16 @@ export function newItemProps(): Pick<Item, "id" | "score" | "createdAt"> {
/**
* Creates a new item in KV. Throws if the item already exists in one of the indexes.
*
* @example New item creation
* @example
* ```ts
* import { newItemProps, createItem } from "@/utils/db.ts";
*
* const item: Item = {
* userLogin: "example-user-login",
* await createItem({
* userLogin: "john_doe",
* title: "example-title",
* url: "https://example.com"
* ..newItemProps(),
* };
*
* await createItem(item);
* url: "https://example.com",
* ...newItemProps(),
* });
* ```
*/
export async function createItem(item: Item) {
Expand Down Expand Up @@ -165,19 +163,17 @@ export function newNotificationProps(): Pick<Item, "id" | "createdAt"> {
/**
* Creates a new notification in KV. Throws if the item already exists in one of the indexes.
*
* @example New notification creation
* @example
* ```ts
* import { newNotificationProps, createNotification } from "@/utils/db.ts";
*
* const notification: Notification = {
* userLogin: "example-user-login",
* await createNotification({
* userLogin: "john_doe",
* type: "example-type",
* text: "Hello, world!",
* originUrl: "https://hunt.deno.land"
* originUrl: "https://hunt.deno.land",
* ...newNotificationProps(),
* };
*
* await createNotification(notification);
* });
* ```
*/
export async function createNotification(notification: Notification) {
Expand Down Expand Up @@ -424,14 +420,13 @@ export function newUserProps(): Pick<User, "isSubscribed"> {
*
* @example
* ```ts
* import { createUser, newUser } from "@/utils/db.ts";
* import { createUser, newUserProps } from "@/utils/db.ts";
*
* const user = {
* login: "login",
* sessionId: "sessionId",
* await createUser({
* login: "john-doe",
* sessionId: crypto.randomUUID(),
* ...newUserProps(),
* };
* await createUser(user);
* });
* ```
*/
export async function createUser(user: User) {
Expand Down
2 changes: 1 addition & 1 deletion utils/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function pluralize(amount: number, unit: string) {
* @example
* ```ts
* import { timeAgo } from "@/utils/display.ts";
* import { SECOND, MINUTE, HOUR } from ""std/datetime/constants.ts""
* import { SECOND, MINUTE, HOUR } from "std/datetime/constants.ts";
*
* timeAgo(new Date()); // Returns "just now"
* timeAgo(new Date(Date.now() - MINUTE)); // Returns "2 minutes ago"
Expand Down

0 comments on commit 0623833

Please sign in to comment.