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

fix(front-matter): improve extract types #5325

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Jul 5, 2024

Currently in std/front-matter package extract functions are typed as Extractor variable, and therefore it doesn't show type information of @params, @returns, etc.

This PR changes them to functions and improves the docs.

BEFORE
Screenshot 2024-07-05 at 13 42 35

AFTER
Screenshot 2024-07-05 at 13 43 45

This PR also exports Extract type (which is return type of extract) from each language file. This resolves #5323

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.80%. Comparing base (6d16b81) to head (7464064).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5325   +/-   ##
=======================================
  Coverage   95.80%   95.80%           
=======================================
  Files         458      458           
  Lines       37852    37864   +12     
  Branches     5562     5562           
=======================================
+ Hits        36264    36276   +12     
  Misses       1548     1548           
  Partials       40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

IIUC, Extractor should no longer be public.

front_matter/any.ts Show resolved Hide resolved
@@ -3,9 +3,15 @@
import { createExtractor, type Parser } from "./_create_extractor.ts";
import { parse as parseYaml } from "@std/yaml/parse";
import { parse as parseToml } from "@std/toml/parse";
import type { Extractor } from "./types.ts";
import type { Extract, Extractor } from "./types.ts";
Copy link
Contributor

Choose a reason for hiding this comment

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

There no longer seems a reason to export Extractor.

Suggested change
import type { Extract, Extractor } from "./types.ts";
import type { Extract } from "./types.ts";


export type { Extractor };
export type { Extract, Extractor };
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export type { Extract, Extractor };
export type { Extract };

Comment on lines +10 to +14
const _extractor = createExtractor({
yaml: parseYaml as Parser,
toml: parseToml as Parser,
json: JSON.parse as Parser,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const _extractor = createExtractor({
yaml: parseYaml as Parser,
toml: parseToml as Parser,
json: JSON.parse as Parser,
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto for the other files

@kt3k
Copy link
Member Author

kt3k commented Jul 5, 2024

Extractor should no longer be public.

I'll do that in a later PR with BREAKING tag.

@kt3k kt3k merged commit 25aa6fa into denoland:main Jul 5, 2024
13 checks passed
@kt3k kt3k deleted the fix-improve-front-matter-extract-types branch July 5, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-export the type for @std/front-matter
2 participants