Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions docs/_includes/home.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 30 additions & 10 deletions docs/reference/index.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/reference/interfaces/GitRepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ An optional branch name.

#### Defined in

[types.ts:68](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L68)
[types.ts:68](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L68)

___

Expand All @@ -44,7 +44,7 @@ The file pattern / glob to match.

#### Defined in

[types.ts:58](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L58)
[types.ts:58](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L58)

___

Expand All @@ -62,7 +62,7 @@ false

#### Defined in

[types.ts:63](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L63)
[types.ts:63](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L63)

___

Expand All @@ -74,7 +74,7 @@ The remote Git repository URL.

#### Defined in

[types.ts:56](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L56)
[types.ts:56](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L56)

___

Expand All @@ -92,4 +92,4 @@ The directory where the repo should be cloned to.

#### Defined in

[types.ts:73](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L73)
[types.ts:73](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L73)
4 changes: 2 additions & 2 deletions docs/reference/interfaces/LocalPath.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The relative or absolute path.

#### Defined in

[types.ts:45](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L45)
[types.ts:45](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L45)

___

Expand All @@ -35,4 +35,4 @@ The file pattern / glob to match.

#### Defined in

[types.ts:47](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L47)
[types.ts:47](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L47)
18 changes: 9 additions & 9 deletions docs/reference/interfaces/Snippet.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The snippet content. Leading spaces are trimmed.

#### Defined in

[types.ts:20](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L20)
[types.ts:20](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L20)

___

Expand All @@ -39,7 +39,7 @@ The end line of the snippet.

#### Defined in

[types.ts:16](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L16)
[types.ts:16](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L16)

___

Expand All @@ -51,7 +51,7 @@ The name of the file, derived from `sourcePath`.

#### Defined in

[types.ts:12](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L12)
[types.ts:12](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L12)

___

Expand All @@ -63,7 +63,7 @@ The lines to be highlighted, if any.

#### Defined in

[types.ts:18](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L18)
[types.ts:18](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L18)

___

Expand All @@ -75,7 +75,7 @@ The source language. It matches the file extension.

#### Defined in

[types.ts:8](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L8)
[types.ts:8](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L8)

___

Expand All @@ -87,7 +87,7 @@ The link to the file on the remote Git repo when available.

#### Defined in

[types.ts:22](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L22)
[types.ts:22](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L22)

___

Expand All @@ -100,7 +100,7 @@ that might come from the same file extension.

#### Defined in

[types.ts:27](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L27)
[types.ts:27](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L27)

___

Expand All @@ -112,7 +112,7 @@ The file path relative to the working directory.

#### Defined in

[types.ts:10](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L10)
[types.ts:10](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L10)

___

Expand All @@ -124,4 +124,4 @@ The start line of the snippet.

#### Defined in

[types.ts:14](https://github.com/roxlabs/coldsnip/blob/f9e1b95/src/types.ts#L14)
[types.ts:14](https://github.com/roxlabs/coldsnip/blob/3c9352e/src/types.ts#L14)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"docs:readme": "cp README.md ./docs/_includes/home.md",
"docs:coldsnip": "./bin/run generate --source=./src --pattern=**/*.ts --format=include",
"docs:typedoc": "typedoc --tsconfig tsconfig.lib.json",
"docs": "npm run docs:readme & npm run docs:typedoc",
"docs": "npm run docs:readme && npm run docs:typedoc",
"format:imports": "organize-imports-cli tsconfig.json",
"format:prettier": "prettier --write \"./**/*.{js,json,ts}\"",
"format:check": "prettier --check \"./**/*.{js,json,ts}\"",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/createSnippet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("the createSnippet test suite", () => {
const snippet = createSnippet({
filePath: "src/index.ts",
repoUrl: "https://github.com/roxlabs/coldsnip",
commit: "d16f69f4eb4f46855c66420c02c586138fb38fcf",
branch: "main",
directory: "./",
startLine: 1,
endLine: 2,
Expand Down
11 changes: 7 additions & 4 deletions src/__tests__/extractSnippets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import extractSnippets, { findFiles } from "../extractSnippets";

describe("the extractSnippets public API test suite", () => {
it("should find the files from all sources", async () => {
const result = await findFiles([
{ path: "./", pattern: "src/__tests__/snippets/*.js" },
{ url: "https://github.com/drochetti/drochetti", pattern: "*.md" },
]);
const result = await findFiles(
[
{ path: "./", pattern: "src/__tests__/snippets/*.js" },
{ url: "https://github.com/drochetti/drochetti", pattern: "*.md" },
],
{ branch: "main" },
);
const paths: string[] = [];
result.forEach(([files, source]) => {
paths.push(...files);
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/git.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,47 @@ describe("the Git repo test suite", () => {
it("should resolve the permalink for GitHub repos", () => {
const permalink = getPermalink({
repoUrl: "https://github.com/roxlabs/coldsnip",
commit: "d16f69f4eb4f46855c66420c02c586138fb38fcf",
branch: "main",
path: "src/index.ts",
startLine: 1,
endLine: 3,
});
expect(permalink).toBe(
"https://github.com/roxlabs/coldsnip/blob/d16f69f4eb4f46855c66420c02c586138fb38fcf/src/index.ts#L1-L3",
"https://github.com/roxlabs/coldsnip/blob/main/src/index.ts#L1-L3",
);
});

it("should resolve the permalink for GitLab repos", () => {
const permalink = getPermalink({
repoUrl: "https://gitlab.com/gitlab-org/gitlab",
commit: "12ecbd8580e13bd385729772102f86bcecfda04f",
branch: "develop",
path: "package.json",
startLine: 4,
endLine: 9,
});
expect(permalink).toBe(
"https://gitlab.com/gitlab-org/gitlab/-/blob/12ecbd8580e13bd385729772102f86bcecfda04f/package.json#L4-9",
"https://gitlab.com/gitlab-org/gitlab/-/blob/develop/package.json#L4-9",
);
});

it("should resolve the permalink for BitBucket repos", () => {
const permalink = getPermalink({
repoUrl: "https://bitbucket.org/atlassian/npm-publish",
commit: "81c90f7e6b1c0859652bf6bd0dc478d99c37d6ac",
branch: "staging",
path: "test/test.py",
startLine: 22,
endLine: 27,
});
expect(permalink).toBe(
"https://bitbucket.org/atlassian/npm-publish/src/81c90f7e6b1c0859652bf6bd0dc478d99c37d6ac/test/test.py#lines-22:27",
"https://bitbucket.org/atlassian/npm-publish/src/staging/test/test.py#lines-22:27",
);
});

it("should throw an error on unsupported Git providers", () => {
expect(() => {
getPermalink({
repoUrl: "https://unsupported.provider.com/cool/repo",
commit: "main",
branch: "main",
path: "README.md",
startLine: 1,
endLine: 2,
Expand Down
Loading