From 8fa44ed3c92ab1e94282606efdd222fd125e14f1 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Thu, 29 Feb 2024 13:32:30 -0500 Subject: [PATCH 01/14] rename module.md to hype.md --- .github/workflows/hype.yml | 41 +++--- .hype/actions/hype.yml | 41 +++--- .hype/module.md | 12 +- .hype/quickstart/module.md | 26 ++-- Makefile | 2 +- README.md | 118 +++++++++--------- binding/part.go | 2 +- binding/part_test.go | 14 +-- .../toc/01-one/{module.md => hype.md} | 0 .../01-one/{module.tex.gold => hype.tex.gold} | 0 .../toc/02-two/{module.md => hype.md} | 0 .../02-two/{module.tex.gold => hype.tex.gold} | 0 .../toc/03-three/{module.md => hype.md} | 0 .../{module.tex.gold => hype.tex.gold} | 0 .../simple/01-one/{module.md => hype.md} | 0 .../simple/02-two/{module.md => hype.md} | 0 .../simple/03-three/{module.md => hype.md} | 0 binding/whole.go | 2 +- cmd/hype/cli/binding.go | 2 +- cmd/hype/cli/encode_test.go | 4 +- cmd/hype/cli/export.go | 2 +- cmd/hype/cli/marked.go | 2 +- cmd/hype/cli/marked_test.go | 2 +- cmd/hype/cli/slides.go | 2 +- .../encode/json/{module.md => hype.md} | 0 .../encode/json/success/execute-file.json | 16 +-- .../encode/json/success/parse-file.json | 16 +-- .../file/{module.tex.gold => hype.tex.gold} | 0 .../latex/multi/one/{module.md => hype.md} | 0 .../one/{module.tex.gold => hype.tex.gold} | 0 .../latex/multi/three/{module.md => hype.md} | 0 .../three/{module.tex.gold => hype.tex.gold} | 0 .../latex/multi/two/{module.md => hype.md} | 0 .../two/{module.tex.gold => hype.tex.gold} | 0 .../latex/simple/{module.md => hype.md} | 0 .../simple/{module.tex.gold => hype.tex.gold} | 0 .../simple/01-one/{module.md => hype.md} | 0 .../simple/02-two/{module.md => hype.md} | 0 .../simple/03-three/{module.md => hype.md} | 0 document_test.go | 14 +-- execute_error_test.go | 6 +- finders_test.go | 4 +- hype_test.go | 6 +- include_test.go | 16 +-- md_test.go | 2 +- mdx/parser_test.go | 2 +- mdx/testdata/{module.md => hype.md} | 0 metadata_test.go | 4 +- now_test.go | 4 +- page_test.go | 2 +- parser.go | 2 +- parser_test.go | 2 +- post_execute_error_test.go | 2 +- post_parse_error_test.go | 4 +- post_parser_test.go | 2 +- pre_execute_error_test.go | 4 +- pre_parse_error_test.go | 6 +- ref_processor_test.go | 4 +- table_test.go | 4 +- .../html/{module.gold => hype.gold} | 0 .../blockquote/html/{module.md => hype.md} | 0 .../blockquote/md/{module.gold => hype.gold} | 0 .../auto/blockquote/md/{module.md => hype.md} | 0 .../commands/greet/{module.gold => hype.gold} | 0 .../commands/greet/{module.md => hype.md} | 0 .../results/data/{module.gold => hype.gold} | 0 .../results/data/{module.md => hype.md} | 0 .../truncate/{module.gold => hype.gold} | 0 .../results/truncate/{module.md => hype.md} | 0 .../side-by-side/{module.gold => hype.gold} | 0 .../side-by-side/{module.md => hype.md} | 0 .../simple/{module.gold => hype.gold} | 0 .../metadata/simple/{module.md => hype.md} | 0 .../parser/hello/{module.gold => hype.gold} | 0 .../auto/parser/hello/{module.md => hype.md} | 0 .../refs/fenced/{module.gold => hype.gold} | 0 .../auto/refs/fenced/{module.md => hype.md} | 0 .../figure-styles/{module.gold => hype.gold} | 0 .../refs/figure-styles/{module.md => hype.md} | 0 .../refs/images/{module.gold => hype.gold} | 0 .../auto/refs/images/{module.md => hype.md} | 0 .../refs/includes/{module.gold => hype.gold} | 0 .../auto/refs/includes/{module.md => hype.md} | 0 .../refs/simple/{module.gold => hype.gold} | 0 .../auto/refs/simple/{module.md => hype.md} | 0 .../snippets/range/{module.gold => hype.gold} | 0 .../snippets/range/{module.md => hype.md} | 0 .../simple/{module.gold => hype.gold} | 0 .../snippets/simple/{module.md => hype.md} | 0 testdata/auto/toc/{module.gold => hype.gold} | 0 testdata/auto/toc/{module.md => hype.md} | 0 .../vars/details/{module.gold => hype.gold} | 0 .../auto/vars/details/{module.md => hype.md} | 0 .../vars/metadata/{module.gold => hype.gold} | 0 .../auto/vars/metadata/{module.md => hype.md} | 0 .../vars/var_tag/{module.gold => hype.gold} | 0 .../auto/vars/var_tag/{module.md => hype.md} | 0 .../execution/failure/{module.md => hype.md} | 0 .../nested_failure/{module.md => hype.md} | 0 .../execution/success/{module.md => hype.md} | 0 testdata/doc/pages/{module.md => hype.md} | 0 testdata/doc/simple/{module.md => hype.md} | 0 testdata/doc/snippets/{module.md => hype.md} | 0 testdata/doc/to_md/{module.gold => hype.gold} | 0 testdata/doc/to_md/{module.md => hype.md} | 0 .../includes/broken/{module.md => hype.md} | 0 .../includes/sublevel/{module.md => hype.md} | 0 .../includes/toplevel/{module.md => hype.md} | 0 testdata/json/document.json | 22 ++-- testdata/json/execute_error.json | 2 +- testdata/json/pre_execute_error.json | 2 +- testdata/json/pre_parse_error.json | 2 +- testdata/json/table.json | 30 ++--- .../unknown-atom/{module.md => hype.md} | 0 .../metadata/multi/{module.md => hype.md} | 0 .../metadata/pages/{module.md => hype.md} | 0 testdata/now/{module.gold => hype.gold} | 0 testdata/now/{module.md => hype.md} | 0 .../errors/execute/{module.md => hype.md} | 0 .../folder/01-one/{module.md => hype.md} | 0 .../01-one/{module.tex.gold => hype.tex.gold} | 0 .../folder/02-two/{module.md => hype.md} | 0 .../02-two/{module.tex.gold => hype.tex.gold} | 0 .../folder/03-three/{module.md => hype.md} | 0 .../{module.tex.gold => hype.tex.gold} | 0 .../post_execute/{module.md => hype.md} | 0 .../errors/post_parse/{module.md => hype.md} | 0 .../errors/pre_execute/{module.md => hype.md} | 0 .../errors/pre_parse/{module.md => hype.md} | 0 .../folder/01-one/{module.md => hype.md} | 0 .../01-one/{module.tex.gold => hype.tex.gold} | 0 .../folder/02-two/{module.md => hype.md} | 0 .../02-two/{module.tex.gold => hype.tex.gold} | 0 .../folder/03-three/{module.md => hype.md} | 0 .../{module.tex.gold => hype.tex.gold} | 0 testdata/table/data/{module.md => hype.md} | 0 .../table/headless/{module.gold => hype.gold} | 0 .../table/headless/{module.md => hype.md} | 0 .../md_in_html/{module.gold => hype.gold} | 0 .../table/md_in_html/{module.md => hype.md} | 0 .../table/md_in_md/{module.gold => hype.gold} | 0 .../table/md_in_md/{module.md => hype.md} | 0 testdata/toc/{module.gold => hype.gold} | 0 testdata/toc/{module.md => hype.md} | 0 tmpl_test.go | 2 +- toc_test.go | 4 +- 146 files changed, 224 insertions(+), 234 deletions(-) rename binding/testdata/toc/01-one/{module.md => hype.md} (100%) rename binding/testdata/toc/01-one/{module.tex.gold => hype.tex.gold} (100%) rename binding/testdata/toc/02-two/{module.md => hype.md} (100%) rename binding/testdata/toc/02-two/{module.tex.gold => hype.tex.gold} (100%) rename binding/testdata/toc/03-three/{module.md => hype.md} (100%) rename binding/testdata/toc/03-three/{module.tex.gold => hype.tex.gold} (100%) rename binding/testdata/whole/simple/01-one/{module.md => hype.md} (100%) rename binding/testdata/whole/simple/02-two/{module.md => hype.md} (100%) rename binding/testdata/whole/simple/03-three/{module.md => hype.md} (100%) rename cmd/hype/cli/testdata/encode/json/{module.md => hype.md} (100%) rename cmd/hype/cli/testdata/latex/file/{module.tex.gold => hype.tex.gold} (100%) rename cmd/hype/cli/testdata/latex/multi/one/{module.md => hype.md} (100%) rename cmd/hype/cli/testdata/latex/multi/one/{module.tex.gold => hype.tex.gold} (100%) rename cmd/hype/cli/testdata/latex/multi/three/{module.md => hype.md} (100%) rename cmd/hype/cli/testdata/latex/multi/three/{module.tex.gold => hype.tex.gold} (100%) rename cmd/hype/cli/testdata/latex/multi/two/{module.md => hype.md} (100%) rename cmd/hype/cli/testdata/latex/multi/two/{module.tex.gold => hype.tex.gold} (100%) rename cmd/hype/cli/testdata/latex/simple/{module.md => hype.md} (100%) rename cmd/hype/cli/testdata/latex/simple/{module.tex.gold => hype.tex.gold} (100%) rename cmd/hype/cli/testdata/whole/simple/01-one/{module.md => hype.md} (100%) rename cmd/hype/cli/testdata/whole/simple/02-two/{module.md => hype.md} (100%) rename cmd/hype/cli/testdata/whole/simple/03-three/{module.md => hype.md} (100%) rename mdx/testdata/{module.md => hype.md} (100%) rename testdata/auto/blockquote/html/{module.gold => hype.gold} (100%) rename testdata/auto/blockquote/html/{module.md => hype.md} (100%) rename testdata/auto/blockquote/md/{module.gold => hype.gold} (100%) rename testdata/auto/blockquote/md/{module.md => hype.md} (100%) rename testdata/auto/commands/greet/{module.gold => hype.gold} (100%) rename testdata/auto/commands/greet/{module.md => hype.md} (100%) rename testdata/auto/commands/results/data/{module.gold => hype.gold} (100%) rename testdata/auto/commands/results/data/{module.md => hype.md} (100%) rename testdata/auto/commands/results/truncate/{module.gold => hype.gold} (100%) rename testdata/auto/commands/results/truncate/{module.md => hype.md} (100%) rename testdata/auto/commands/side-by-side/{module.gold => hype.gold} (100%) rename testdata/auto/commands/side-by-side/{module.md => hype.md} (100%) rename testdata/auto/metadata/simple/{module.gold => hype.gold} (100%) rename testdata/auto/metadata/simple/{module.md => hype.md} (100%) rename testdata/auto/parser/hello/{module.gold => hype.gold} (100%) rename testdata/auto/parser/hello/{module.md => hype.md} (100%) rename testdata/auto/refs/fenced/{module.gold => hype.gold} (100%) rename testdata/auto/refs/fenced/{module.md => hype.md} (100%) rename testdata/auto/refs/figure-styles/{module.gold => hype.gold} (100%) rename testdata/auto/refs/figure-styles/{module.md => hype.md} (100%) rename testdata/auto/refs/images/{module.gold => hype.gold} (100%) rename testdata/auto/refs/images/{module.md => hype.md} (100%) rename testdata/auto/refs/includes/{module.gold => hype.gold} (100%) rename testdata/auto/refs/includes/{module.md => hype.md} (100%) rename testdata/auto/refs/simple/{module.gold => hype.gold} (100%) rename testdata/auto/refs/simple/{module.md => hype.md} (100%) rename testdata/auto/snippets/range/{module.gold => hype.gold} (100%) rename testdata/auto/snippets/range/{module.md => hype.md} (100%) rename testdata/auto/snippets/simple/{module.gold => hype.gold} (100%) rename testdata/auto/snippets/simple/{module.md => hype.md} (100%) rename testdata/auto/toc/{module.gold => hype.gold} (100%) rename testdata/auto/toc/{module.md => hype.md} (100%) rename testdata/auto/vars/details/{module.gold => hype.gold} (100%) rename testdata/auto/vars/details/{module.md => hype.md} (100%) rename testdata/auto/vars/metadata/{module.gold => hype.gold} (100%) rename testdata/auto/vars/metadata/{module.md => hype.md} (100%) rename testdata/auto/vars/var_tag/{module.gold => hype.gold} (100%) rename testdata/auto/vars/var_tag/{module.md => hype.md} (100%) rename testdata/doc/execution/failure/{module.md => hype.md} (100%) rename testdata/doc/execution/nested_failure/{module.md => hype.md} (100%) rename testdata/doc/execution/success/{module.md => hype.md} (100%) rename testdata/doc/pages/{module.md => hype.md} (100%) rename testdata/doc/simple/{module.md => hype.md} (100%) rename testdata/doc/snippets/{module.md => hype.md} (100%) rename testdata/doc/to_md/{module.gold => hype.gold} (100%) rename testdata/doc/to_md/{module.md => hype.md} (100%) rename testdata/includes/broken/{module.md => hype.md} (100%) rename testdata/includes/sublevel/{module.md => hype.md} (100%) rename testdata/includes/toplevel/{module.md => hype.md} (100%) rename testdata/markdown/unknown-atom/{module.md => hype.md} (100%) rename testdata/metadata/multi/{module.md => hype.md} (100%) rename testdata/metadata/pages/{module.md => hype.md} (100%) rename testdata/now/{module.gold => hype.gold} (100%) rename testdata/now/{module.md => hype.md} (100%) rename testdata/parser/errors/execute/{module.md => hype.md} (100%) rename testdata/parser/errors/folder/01-one/{module.md => hype.md} (100%) rename testdata/parser/errors/folder/01-one/{module.tex.gold => hype.tex.gold} (100%) rename testdata/parser/errors/folder/02-two/{module.md => hype.md} (100%) rename testdata/parser/errors/folder/02-two/{module.tex.gold => hype.tex.gold} (100%) rename testdata/parser/errors/folder/03-three/{module.md => hype.md} (100%) rename testdata/parser/errors/folder/03-three/{module.tex.gold => hype.tex.gold} (100%) rename testdata/parser/errors/post_execute/{module.md => hype.md} (100%) rename testdata/parser/errors/post_parse/{module.md => hype.md} (100%) rename testdata/parser/errors/pre_execute/{module.md => hype.md} (100%) rename testdata/parser/errors/pre_parse/{module.md => hype.md} (100%) rename testdata/parser/folder/01-one/{module.md => hype.md} (100%) rename testdata/parser/folder/01-one/{module.tex.gold => hype.tex.gold} (100%) rename testdata/parser/folder/02-two/{module.md => hype.md} (100%) rename testdata/parser/folder/02-two/{module.tex.gold => hype.tex.gold} (100%) rename testdata/parser/folder/03-three/{module.md => hype.md} (100%) rename testdata/parser/folder/03-three/{module.tex.gold => hype.tex.gold} (100%) rename testdata/table/data/{module.md => hype.md} (100%) rename testdata/table/headless/{module.gold => hype.gold} (100%) rename testdata/table/headless/{module.md => hype.md} (100%) rename testdata/table/md_in_html/{module.gold => hype.gold} (100%) rename testdata/table/md_in_html/{module.md => hype.md} (100%) rename testdata/table/md_in_md/{module.gold => hype.gold} (100%) rename testdata/table/md_in_md/{module.md => hype.md} (100%) rename testdata/toc/{module.gold => hype.gold} (100%) rename testdata/toc/{module.md => hype.md} (100%) diff --git a/.github/workflows/hype.yml b/.github/workflows/hype.yml index 7928b79..29de8e7 100644 --- a/.github/workflows/hype.yml +++ b/.github/workflows/hype.yml @@ -2,30 +2,29 @@ name: Generate README with Hype on: [pull_request] jobs: - build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.22.x" - cache-dependency-path: subdir/go.sum + - uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22.x" + cache-dependency-path: subdir/go.sum - - name: Install hype - run: go install github.com/gopherguides/hype/cmd/hype@latest + - name: Install hype + run: go install github.com/gopherguides/hype/cmd/hype@latest - - name: Run hype - run: pushd .hype;hype export -format=markdown -f module.md > ../README.md;popd + - name: Run hype + run: pushd .hype;hype export -format=markdown -f hype.md > ../README.md;popd - - name: Commit README back to the repo - run: |- - git rev-parse --abbrev-ref HEAD - git config user.name 'GitHub Actions' - git config user.email 'actions@github.com' - git diff --quiet || (git add README.md && git commit -am "Updated README") - git push origin ${{github.event.pull_request.head.ref}} + - name: Commit README back to the repo + run: |- + git rev-parse --abbrev-ref HEAD + git config user.name 'GitHub Actions' + git config user.email 'actions@github.com' + git diff --quiet || (git add README.md && git commit -am "Updated README") + git push origin ${{github.event.pull_request.head.ref}} diff --git a/.hype/actions/hype.yml b/.hype/actions/hype.yml index 7928b79..29de8e7 100644 --- a/.hype/actions/hype.yml +++ b/.hype/actions/hype.yml @@ -2,30 +2,29 @@ name: Generate README with Hype on: [pull_request] jobs: - build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.22.x" - cache-dependency-path: subdir/go.sum + - uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22.x" + cache-dependency-path: subdir/go.sum - - name: Install hype - run: go install github.com/gopherguides/hype/cmd/hype@latest + - name: Install hype + run: go install github.com/gopherguides/hype/cmd/hype@latest - - name: Run hype - run: pushd .hype;hype export -format=markdown -f module.md > ../README.md;popd + - name: Run hype + run: pushd .hype;hype export -format=markdown -f hype.md > ../README.md;popd - - name: Commit README back to the repo - run: |- - git rev-parse --abbrev-ref HEAD - git config user.name 'GitHub Actions' - git config user.email 'actions@github.com' - git diff --quiet || (git add README.md && git commit -am "Updated README") - git push origin ${{github.event.pull_request.head.ref}} + - name: Commit README back to the repo + run: |- + git rev-parse --abbrev-ref HEAD + git config user.name 'GitHub Actions' + git config user.email 'actions@github.com' + git diff --quiet || (git add README.md && git commit -am "Updated README") + git push origin ${{github.event.pull_request.head.ref}} diff --git a/.hype/module.md b/.hype/module.md index b112dd9..5cc063f 100644 --- a/.hype/module.md +++ b/.hype/module.md @@ -1,9 +1,11 @@ # Hype + Hype is a content generation tool that use traditional Markdown syntax, and allows it to be extended for almost any use to create dynamic, rich, automated output that is easily maintainable and reusable. Hype follows the same principals that we use for coding; + - packages (keep relevant content in small, reusable packages, with all links relative to the package) - reuse - write your documentation once (even in your code), and use everywhere (blog, book, github repo, etc) - partials/includes - support including documents into a larger document (just like code!) @@ -12,18 +14,17 @@ Hype follows the same principals that we use for coding; ## Created with Hype -This README was created with hype. Here was the command we used to create it: +This README was created with hype. Here was the command we used to create it: From the `.hype` directory, run: ``` -hype export -format=markdown -f module.md > ../README.md +hype export -format=markdown -f hype.md > ../README.md ``` You can also use a [github action](#using-github-actions-to-update-your-readme) to automatically update your README as well. - - + # README Source @@ -33,8 +34,7 @@ Here is the current structure that we are using to create this readme: - - + # Issues diff --git a/.hype/quickstart/module.md b/.hype/quickstart/module.md index b8552b8..dcc7071 100644 --- a/.hype/quickstart/module.md +++ b/.hype/quickstart/module.md @@ -1,6 +1,6 @@ # Quick Start Guide -For more in depth examples, you can read our quick start guide +For more in depth examples, you can read our quick start guide [here](https://www.gopherguides.com/articles/golang-hype-quickstart). # The Basics @@ -31,7 +31,7 @@ func main() { // snippet: example ``` -Notice the use of the `snippet` comment. The format for the comment is: +Notice the use of the `snippet` comment. The format for the comment is: ``` // snippet: @@ -43,13 +43,13 @@ The output of including that tag will be as follows: -A `snippet` is not required in your `code` tag. They default behavior of a `code` tag is to include the entire source file. +A `snippet` is not required in your `code` tag. They default behavior of a `code` tag is to include the entire source file. If we leave the tag out, it will result in the following code being included: -Notice that none of the `snippet` comments were in the output? This is because hype recognizes them as directives for the document, and will not show them in the actual output. +Notice that none of the `snippet` comments were in the output? This is because hype recognizes them as directives for the document, and will not show them in the actual output. # Go Specific Commands @@ -57,7 +57,7 @@ There are a number of [Go](https://go.dev/) specific commands you can run as wel Let's look at how we use the `go` tag. -Here is the source code of the Go file we are going to include. Notice the use of the `snippet` comments to identify the area of code we want included. We'll see how to specify that in the next section when we include it in our markdown. +Here is the source code of the Go file we are going to include. Notice the use of the `snippet` comments to identify the area of code we want included. We'll see how to specify that in the next section when we include it in our markdown. # Running Go Code @@ -66,6 +66,7 @@ The following command will include the go source code, run it, and include the o ``` ``` + Here is the result that will be included in your document from the above command: @@ -84,7 +85,7 @@ Now the source code is includes, as well as the output of the program: ## Snippets with Go -You can also specify the snippet in a `go` tag as well. The result is that it will only include the code snippet in the included source: +You can also specify the snippet in a `go` tag as well. The result is that it will only include the code snippet in the included source: ``` @@ -96,7 +97,7 @@ You can see now that only the snippet is included, but the output is still the s ## Invalid Code -What if you want to include an example of code that does not compile? We still want the code to be parsed and included, even though the code doesn't compile. For this, we can state the expected output of the program. +What if you want to include an example of code that does not compile? We still want the code to be parsed and included, even though the code doesn't compile. For this, we can state the expected output of the program. ``` @@ -108,7 +109,7 @@ The result now includes the snippet, and the error output from trying to compile ### GoDoc -While there are a number of `godoc` commands that will allow you to put your documentation from your code directly into your articles as well. Here are some of the commands. +While there are a number of `godoc` commands that will allow you to put your documentation from your code directly into your articles as well. Here are some of the commands. Here is the basic usage first: @@ -131,10 +132,9 @@ Here is the output for the above command: For more examples, see the [hype repo](https://www.github.com/gopherguides/hype). - # Arbitrary Commands -You can also use the `cmd` tag and the `exec` attribute to run arbitrary commands and include them in your documentation. Here is the command to run the `tree` command and include it in our documentation: +You can also use the `cmd` tag and the `exec` attribute to run arbitrary commands and include them in your documentation. Here is the command to run the `tree` command and include it in our documentation: ``` @@ -146,14 +146,14 @@ Here is the output: # The Export Command -There are several options for running the `hype` command. Most notable is the `export` option: +There are several options for running the `hype` command. Most notable is the `export` option: ``` $ hype export -h Usage of hype: -f string - optional file name to preview, if not provided, defaults to module.md (default "module.md") + optional file name to preview, if not provided, defaults to hype.md (default "hype.md") -format string content type to export to: markdown, html (default "markdown") -timeout duration @@ -179,5 +179,3 @@ The paths specified in the src attribute of the include are relative to the mark The following code will parse the code/code.md and sourceable/sourceable.md documents and append them to the end of the document they were included in. - - diff --git a/Makefile b/Makefile index 68abf1b..2efe42e 100644 --- a/Makefile +++ b/Makefile @@ -15,4 +15,4 @@ install: go install -v ./cmd/hype hype: - pushd .hype;hype export -format=markdown -f module.md > ../README.md;popd + pushd .hype;hype export -format=markdown -f hype.md > ../README.md;popd diff --git a/README.md b/README.md index 2acb0ac..f83f3d4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - [Release](https://github.com/gopherguides/hype/releases/latest) [Go Build Status](https://github.com/gopherguides/hype/actions) [Go Reference](https://pkg.go.dev/github.com/gopherguides/hype) @@ -12,6 +11,7 @@ Hype is a content generation tool that use traditional Markdown syntax, and allows it to be extended for almost any use to create dynamic, rich, automated output that is easily maintainable and reusable. Hype follows the same principals that we use for coding; + - packages (keep relevant content in small, reusable packages, with all links relative to the package) - reuse - write your documentation once (even in your code), and use everywhere (blog, book, github repo, etc) - partials/includes - support including documents into a larger document (just like code!) @@ -20,11 +20,11 @@ Hype follows the same principals that we use for coding; ## Created with Hype -This README was created with hype. Here was the command we used to create it: +This README was created with hype. Here was the command we used to create it: From the `.hype` directory, run: -`hype export -format=markdown -f module.md > ../README.md +`hype export -format=markdown -f hype.md > ../README.md ` You can also use a [github action](#using-github-actions-to-update-your-readme) to automatically update your README as well. @@ -45,10 +45,8 @@ This is the syntax to include a code sample in your document: The above code snippet does the following: - -* Includes the code snippet specified in the source code -* Validates that the code compiles - +- Includes the code snippet specified in the source code +- Validates that the code compiles Here is the source file: @@ -66,7 +64,7 @@ func main() { ``` -Notice the use of the `snippet` comment. The format for the comment is: +Notice the use of the `snippet` comment. The format for the comment is: `// snippet: ` @@ -81,7 +79,7 @@ func main() { } ``` -A `snippet` is not required in your `code` tag. They default behavior of a `code` tag is to include the entire source file. +A `snippet` is not required in your `code` tag. They default behavior of a `code` tag is to include the entire source file. If we leave the tag out, it will result in the following code being included: @@ -97,7 +95,7 @@ func main() { ``` -Notice that none of the `snippet` comments were in the output? This is because hype recognizes them as directives for the document, and will not show them in the actual output. +Notice that none of the `snippet` comments were in the output? This is because hype recognizes them as directives for the document, and will not show them in the actual output. # Go Specific Commands @@ -105,7 +103,7 @@ There are a number of [Go](https://go.dev/) specific commands you can run as wel Let's look at how we use the `go` tag. -Here is the source code of the Go file we are going to include. Notice the use of the `snippet` comments to identify the area of code we want included. We'll see how to specify that in the next section when we include it in our markdown. +Here is the source code of the Go file we are going to include. Notice the use of the `snippet` comments to identify the area of code we want included. We'll see how to specify that in the next section when we include it in our markdown. # Running Go Code @@ -161,7 +159,7 @@ Go Version: go1.22.0 ## Snippets with Go -You can also specify the snippet in a `go` tag as well. The result is that it will only include the code snippet in the included source: +You can also specify the snippet in a `go` tag as well. The result is that it will only include the code snippet in the included source: ` ` @@ -188,7 +186,7 @@ Go Version: go1.22.0 ## Invalid Code -What if you want to include an example of code that does not compile? We still want the code to be parsed and included, even though the code doesn't compile. For this, we can state the expected output of the program. +What if you want to include an example of code that does not compile? We still want the code to be parsed and included, even though the code doesn't compile. For this, we can state the expected output of the program. ` ` @@ -216,7 +214,7 @@ Go Version: go1.22.0 ### GoDoc -While there are a number of `godoc` commands that will allow you to put your documentation from your code directly into your articles as well. Here are some of the commands. +While there are a number of `godoc` commands that will allow you to put your documentation from your code directly into your articles as well. Here are some of the commands. Here is the basic usage first: @@ -257,6 +255,7 @@ You can also be more specific. ` Here is the output for the above command: + ```shell $ go doc -short context.WithCancel @@ -278,7 +277,7 @@ For more examples, see the [hype repo](https://www.github.com/gopherguides/hype) # Arbitrary Commands -You can also use the `cmd` tag and the `exec` attribute to run arbitrary commands and include them in your documentation. Here is the command to run the `tree` command and include it in our documentation: +You can also use the `cmd` tag and the `exec` attribute to run arbitrary commands and include them in your documentation. Here is the command to run the `tree` command and include it in our documentation: ` ` @@ -290,7 +289,7 @@ $ tree . ├── includes.md -├── module.md +├── hype.md └── src ├── broken │   └── main.go @@ -302,25 +301,25 @@ $ tree # The Export Command -There are several options for running the `hype` command. Most notable is the `export` option: +There are several options for running the `hype` command. Most notable is the `export` option: `$ hype export -h Usage of hype: - -f string - optional file name to preview, if not provided, defaults to module.md (default "module.md") - -format string - content type to export to: markdown, html (default "markdown") - -timeout duration - timeout for execution, defaults to 30 seconds (30s) (default 5s) - -v enable verbose output for debugging +-f string +optional file name to preview, if not provided, defaults to hype.md (default "hype.md") +-format string +content type to export to: markdown, html (default "markdown") +-timeout duration +timeout for execution, defaults to 30 seconds (30s) (default 5s) +-v enable verbose output for debugging Usage: hype export [options] Examples: - hype export -format html - hype export -f README.md -format html - hype export -f README.md -format markdown -timeout=10s +hype export -format html +hype export -f README.md -format html +hype export -f README.md -format markdown -timeout=10s ` This allows you to see your compiled document either as a single markdown, or as an html document that you can preview in the browser. @@ -337,7 +336,6 @@ The following code will parse the code/code.md and sourceable/sourceable.md docu - ``` --- @@ -354,13 +352,13 @@ $ tree . ├── actions │   ├── hype.yml -│   └── module.md +│   └── hype.md ├── badges.md ├── license.md -├── module.md +├── hype.md └── quickstart ├── includes.md - ├── module.md + ├── hype.md └── src ├── broken │   └── main.go @@ -369,6 +367,7 @@ $ tree 5 directories, 9 files ``` + --- # Using Github Actions to update your README @@ -385,10 +384,8 @@ You need to give permission to your GitHub Actions to create a pull request in y Under `Workflow Permissions` - -* Check `Allow GitHub Actions to create and approve pull requests`. -* Check `Read and write permissions` - +- Check `Allow GitHub Actions to create and approve pull requests`. +- Check `Read and write permissions` ### Personal Access Token @@ -398,41 +395,39 @@ It is recommend to use a GitHub [Personnal Acces Token](https://docs.github.com/ ## The Action -The current action is set to only generate the readme on a pull request and commit it back to that same pull request. You can modify this to your own needs. +The current action is set to only generate the readme on a pull request and commit it back to that same pull request. You can modify this to your own needs. ```yml name: Generate README with Hype on: [pull_request] jobs: - build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.22.x" - cache-dependency-path: subdir/go.sum - - - name: Install hype - run: go install github.com/gopherguides/hype/cmd/hype@latest - - - name: Run hype - run: pushd .hype;hype export -format=markdown -f module.md > ../README.md;popd - - - name: Commit README back to the repo - run: |- - git rev-parse --abbrev-ref HEAD - git config user.name 'GitHub Actions' - git config user.email 'actions@github.com' - git diff --quiet || (git add README.md && git commit -am "Updated README") - git push origin ${{github.event.pull_request.head.ref}} - + - uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22.x" + cache-dependency-path: subdir/go.sum + + - name: Install hype + run: go install github.com/gopherguides/hype/cmd/hype@latest + + - name: Run hype + run: pushd .hype;hype export -format=markdown -f hype.md > ../README.md;popd + + - name: Commit README back to the repo + run: |- + git rev-parse --abbrev-ref HEAD + git config user.name 'GitHub Actions' + git config user.email 'actions@github.com' + git diff --quiet || (git add README.md && git commit -am "Updated README") + git push origin ${{github.event.pull_request.head.ref}} ``` --- @@ -446,4 +441,3 @@ There are several issues that still need to be worked on. Please see the issues # License [Hype](https://github.com/gopherguides/hype) by [Gopher Guides LLC](https://github.com/gopherguides) is licensed under [Attribution-NonCommercial-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-nc-sa/4.0/?ref=chooser-v1) - diff --git a/binding/part.go b/binding/part.go index c94b652..b7ab2fe 100644 --- a/binding/part.go +++ b/binding/part.go @@ -94,7 +94,7 @@ func PartFromPath(cab fs.FS, mp string) (Part, error) { part.Name = flect.New(name) - fp := filepath.Join(mp, "module.md") + fp := filepath.Join(mp, "hype.md") if _, err := fs.Stat(cab, fp); err != nil { return part, nil diff --git a/binding/part_test.go b/binding/part_test.go index 50e4883..e3c07c9 100644 --- a/binding/part_test.go +++ b/binding/part_test.go @@ -17,22 +17,22 @@ func Test_PartFromPath(t *testing.T) { err bool }{ {in: `.`, err: true}, - {in: `01-foo/module.md`, num: 1, name: "foo"}, + {in: `01-foo/hype.md`, num: 1, name: "foo"}, {in: `01-foo`, num: 1, name: "foo"}, {in: `01-pkgs-mods-deps`, num: 1, name: "pkgs-mods-deps"}, - {in: `012-foo/module.md`, num: 12, name: "foo"}, + {in: `012-foo/hype.md`, num: 12, name: "foo"}, {in: `012-foo`, num: 12, name: "foo"}, - {in: `01234-foo/module.md`, num: 1234, name: "foo"}, + {in: `01234-foo/hype.md`, num: 1234, name: "foo"}, {in: `01234-foo`, num: 1234, name: "foo"}, - {in: `1-foo/module.md`, num: 1, name: "foo"}, + {in: `1-foo/hype.md`, num: 1, name: "foo"}, {in: `1-foo`, num: 1, name: "foo"}, - {in: `12-foo/module.md`, num: 12, name: "foo"}, + {in: `12-foo/hype.md`, num: 12, name: "foo"}, {in: `12-foo`, num: 12, name: "foo"}, - {in: `1234-foo/module.md`, num: 1234, name: "foo"}, + {in: `1234-foo/hype.md`, num: 1234, name: "foo"}, {in: `1234-foo`, num: 1234, name: "foo"}, {in: ``, err: true}, {in: `foo.md`, err: true}, - {in: `src/simple/1-foo/module.md`, num: 1, name: "foo"}, + {in: `src/simple/1-foo/hype.md`, num: 1, name: "foo"}, } for _, tc := range tcs { diff --git a/binding/testdata/toc/01-one/module.md b/binding/testdata/toc/01-one/hype.md similarity index 100% rename from binding/testdata/toc/01-one/module.md rename to binding/testdata/toc/01-one/hype.md diff --git a/binding/testdata/toc/01-one/module.tex.gold b/binding/testdata/toc/01-one/hype.tex.gold similarity index 100% rename from binding/testdata/toc/01-one/module.tex.gold rename to binding/testdata/toc/01-one/hype.tex.gold diff --git a/binding/testdata/toc/02-two/module.md b/binding/testdata/toc/02-two/hype.md similarity index 100% rename from binding/testdata/toc/02-two/module.md rename to binding/testdata/toc/02-two/hype.md diff --git a/binding/testdata/toc/02-two/module.tex.gold b/binding/testdata/toc/02-two/hype.tex.gold similarity index 100% rename from binding/testdata/toc/02-two/module.tex.gold rename to binding/testdata/toc/02-two/hype.tex.gold diff --git a/binding/testdata/toc/03-three/module.md b/binding/testdata/toc/03-three/hype.md similarity index 100% rename from binding/testdata/toc/03-three/module.md rename to binding/testdata/toc/03-three/hype.md diff --git a/binding/testdata/toc/03-three/module.tex.gold b/binding/testdata/toc/03-three/hype.tex.gold similarity index 100% rename from binding/testdata/toc/03-three/module.tex.gold rename to binding/testdata/toc/03-three/hype.tex.gold diff --git a/binding/testdata/whole/simple/01-one/module.md b/binding/testdata/whole/simple/01-one/hype.md similarity index 100% rename from binding/testdata/whole/simple/01-one/module.md rename to binding/testdata/whole/simple/01-one/hype.md diff --git a/binding/testdata/whole/simple/02-two/module.md b/binding/testdata/whole/simple/02-two/hype.md similarity index 100% rename from binding/testdata/whole/simple/02-two/module.md rename to binding/testdata/whole/simple/02-two/hype.md diff --git a/binding/testdata/whole/simple/03-three/module.md b/binding/testdata/whole/simple/03-three/hype.md similarity index 100% rename from binding/testdata/whole/simple/03-three/module.md rename to binding/testdata/whole/simple/03-three/hype.md diff --git a/binding/whole.go b/binding/whole.go index c67502a..c95a100 100644 --- a/binding/whole.go +++ b/binding/whole.go @@ -67,7 +67,7 @@ func WholeFromPath(cab fs.FS, root string, wholeName string, partName string) (* } base := filepath.Base(path) - if base != "module.md" { + if base != "hype.md" { return nil } diff --git a/cmd/hype/cli/binding.go b/cmd/hype/cli/binding.go index e2329b2..e5cd089 100644 --- a/cmd/hype/cli/binding.go +++ b/cmd/hype/cli/binding.go @@ -105,7 +105,7 @@ func (b *Binding) parseParts(p *hype.Parser, key string) error { return b.WrapErr(err) } - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") if err != nil { return b.WrapErr(err) } diff --git a/cmd/hype/cli/encode_test.go b/cmd/hype/cli/encode_test.go index ea55b14..163568f 100644 --- a/cmd/hype/cli/encode_test.go +++ b/cmd/hype/cli/encode_test.go @@ -60,8 +60,8 @@ func Test_Encode_JSON(t *testing.T) { args []string exp string }{ - {name: "execute file", exp: "success/execute-file.json", args: []string{"module.md"}}, - {name: "parse file", exp: "success/parse-file.json", args: []string{"-p", "module.md"}}, + {name: "execute file", exp: "success/execute-file.json", args: []string{"hype.md"}}, + {name: "parse file", exp: "success/parse-file.json", args: []string{"-p", "hype.md"}}, } for _, tc := range tcs { diff --git a/cmd/hype/cli/export.go b/cmd/hype/cli/export.go index 6f27146..2b70118 100644 --- a/cmd/hype/cli/export.go +++ b/cmd/hype/cli/export.go @@ -96,7 +96,7 @@ Examples: cmd.flags = flag.NewFlagSet("export", flag.ContinueOnError) cmd.flags.SetOutput(stderr) cmd.flags.DurationVar(&cmd.Timeout, "timeout", DefaultTimeout(), "timeout for execution, defaults to 30 seconds (30s)") - cmd.flags.StringVar(&cmd.File, "f", "module.md", "optional file name to preview, if not provided, defaults to module.md") + cmd.flags.StringVar(&cmd.File, "f", "hype.md", "optional file name to preview, if not provided, defaults to hype.md") cmd.flags.BoolVar(&cmd.Verbose, "v", false, "enable verbose output for debugging") cmd.flags.StringVar(&cmd.Format, "format", "markdown", "content type to export to: markdown, html") diff --git a/cmd/hype/cli/marked.go b/cmd/hype/cli/marked.go index a7995ef..8f11bc5 100644 --- a/cmd/hype/cli/marked.go +++ b/cmd/hype/cli/marked.go @@ -91,7 +91,7 @@ func (cmd *Marked) Flags() (*flag.FlagSet, error) { cmd.flags.BoolVar(&cmd.ParseOnly, "p", cmd.ParseOnly, "if true, only parse the file and exit") cmd.flags.DurationVar(&cmd.Timeout, "timeout", DefaultTimeout(), "timeout for execution") cmd.flags.StringVar(&cmd.ContextPath, "context", cmd.ContextPath, "a folder containing all chapters of a book, for example") - cmd.flags.StringVar(&cmd.File, "f", cmd.File, "optional file name to preview, if not provided, defaults to module.md") + cmd.flags.StringVar(&cmd.File, "f", cmd.File, "optional file name to preview, if not provided, defaults to hype.md") cmd.flags.IntVar(&cmd.Section, "section", 0, "") cmd.flags.BoolVar(&cmd.Verbose, "v", false, "enable verbose output for debugging") diff --git a/cmd/hype/cli/marked_test.go b/cmd/hype/cli/marked_test.go index 76c2d39..7c92d1a 100644 --- a/cmd/hype/cli/marked_test.go +++ b/cmd/hype/cli/marked_test.go @@ -79,7 +79,7 @@ func Test_Marked_Path_Env(t *testing.T) { r := require.New(t) - t.Setenv("MARKED_PATH", "testdata/whole/simple/01-one/module.md") + t.Setenv("MARKED_PATH", "testdata/whole/simple/01-one/hype.md") cmd := &Marked{} diff --git a/cmd/hype/cli/slides.go b/cmd/hype/cli/slides.go index 6cf01c8..10ff8f7 100644 --- a/cmd/hype/cli/slides.go +++ b/cmd/hype/cli/slides.go @@ -57,7 +57,7 @@ func (a *Slides) Main(ctx context.Context, pwd string, args []string) error { a.App.Parser = a.Parser } a.App.PWD = pwd - a.App.FileName = "module.md" + a.App.FileName = "hype.md" if p := flags.Arg(0); len(p) > 0 { a.App.PWD = filepath.Dir(p) diff --git a/cmd/hype/cli/testdata/encode/json/module.md b/cmd/hype/cli/testdata/encode/json/hype.md similarity index 100% rename from cmd/hype/cli/testdata/encode/json/module.md rename to cmd/hype/cli/testdata/encode/json/hype.md diff --git a/cmd/hype/cli/testdata/encode/json/success/execute-file.json b/cmd/hype/cli/testdata/encode/json/success/execute-file.json index b882c24..c37ea23 100644 --- a/cmd/hype/cli/testdata/encode/json/success/execute-file.json +++ b/cmd/hype/cli/testdata/encode/json/success/execute-file.json @@ -1,11 +1,11 @@ { - "filename": "module.md", + "filename": "hype.md", "id": "execute file", "nodes": [ { "atom": "", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "", "data_atom": "", @@ -17,7 +17,7 @@ { "atom": "html", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "html", "data_atom": "html", @@ -29,7 +29,7 @@ { "atom": "head", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "head", "data_atom": "head", @@ -45,7 +45,7 @@ { "atom": "body", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "body", "data_atom": "body", @@ -58,7 +58,7 @@ { "atom": "page", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "page", "data_atom": "", @@ -75,7 +75,7 @@ { "atom": "h1", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "h1", "data_atom": "h1", @@ -104,7 +104,7 @@ "attributes": { "id": "123" }, - "filename": "module.md", + "filename": "hype.md", "html_node": { "attributes": [ { diff --git a/cmd/hype/cli/testdata/encode/json/success/parse-file.json b/cmd/hype/cli/testdata/encode/json/success/parse-file.json index e5f80fc..c2b891c 100644 --- a/cmd/hype/cli/testdata/encode/json/success/parse-file.json +++ b/cmd/hype/cli/testdata/encode/json/success/parse-file.json @@ -1,11 +1,11 @@ { - "filename": "module.md", + "filename": "hype.md", "id": "parse file", "nodes": [ { "atom": "", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "", "data_atom": "", @@ -17,7 +17,7 @@ { "atom": "html", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "html", "data_atom": "html", @@ -29,7 +29,7 @@ { "atom": "head", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "head", "data_atom": "head", @@ -45,7 +45,7 @@ { "atom": "body", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "body", "data_atom": "body", @@ -58,7 +58,7 @@ { "atom": "page", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "page", "data_atom": "", @@ -75,7 +75,7 @@ { "atom": "h1", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "h1", "data_atom": "h1", @@ -104,7 +104,7 @@ "attributes": { "id": "123" }, - "filename": "module.md", + "filename": "hype.md", "html_node": { "attributes": [ { diff --git a/cmd/hype/cli/testdata/latex/file/module.tex.gold b/cmd/hype/cli/testdata/latex/file/hype.tex.gold similarity index 100% rename from cmd/hype/cli/testdata/latex/file/module.tex.gold rename to cmd/hype/cli/testdata/latex/file/hype.tex.gold diff --git a/cmd/hype/cli/testdata/latex/multi/one/module.md b/cmd/hype/cli/testdata/latex/multi/one/hype.md similarity index 100% rename from cmd/hype/cli/testdata/latex/multi/one/module.md rename to cmd/hype/cli/testdata/latex/multi/one/hype.md diff --git a/cmd/hype/cli/testdata/latex/multi/one/module.tex.gold b/cmd/hype/cli/testdata/latex/multi/one/hype.tex.gold similarity index 100% rename from cmd/hype/cli/testdata/latex/multi/one/module.tex.gold rename to cmd/hype/cli/testdata/latex/multi/one/hype.tex.gold diff --git a/cmd/hype/cli/testdata/latex/multi/three/module.md b/cmd/hype/cli/testdata/latex/multi/three/hype.md similarity index 100% rename from cmd/hype/cli/testdata/latex/multi/three/module.md rename to cmd/hype/cli/testdata/latex/multi/three/hype.md diff --git a/cmd/hype/cli/testdata/latex/multi/three/module.tex.gold b/cmd/hype/cli/testdata/latex/multi/three/hype.tex.gold similarity index 100% rename from cmd/hype/cli/testdata/latex/multi/three/module.tex.gold rename to cmd/hype/cli/testdata/latex/multi/three/hype.tex.gold diff --git a/cmd/hype/cli/testdata/latex/multi/two/module.md b/cmd/hype/cli/testdata/latex/multi/two/hype.md similarity index 100% rename from cmd/hype/cli/testdata/latex/multi/two/module.md rename to cmd/hype/cli/testdata/latex/multi/two/hype.md diff --git a/cmd/hype/cli/testdata/latex/multi/two/module.tex.gold b/cmd/hype/cli/testdata/latex/multi/two/hype.tex.gold similarity index 100% rename from cmd/hype/cli/testdata/latex/multi/two/module.tex.gold rename to cmd/hype/cli/testdata/latex/multi/two/hype.tex.gold diff --git a/cmd/hype/cli/testdata/latex/simple/module.md b/cmd/hype/cli/testdata/latex/simple/hype.md similarity index 100% rename from cmd/hype/cli/testdata/latex/simple/module.md rename to cmd/hype/cli/testdata/latex/simple/hype.md diff --git a/cmd/hype/cli/testdata/latex/simple/module.tex.gold b/cmd/hype/cli/testdata/latex/simple/hype.tex.gold similarity index 100% rename from cmd/hype/cli/testdata/latex/simple/module.tex.gold rename to cmd/hype/cli/testdata/latex/simple/hype.tex.gold diff --git a/cmd/hype/cli/testdata/whole/simple/01-one/module.md b/cmd/hype/cli/testdata/whole/simple/01-one/hype.md similarity index 100% rename from cmd/hype/cli/testdata/whole/simple/01-one/module.md rename to cmd/hype/cli/testdata/whole/simple/01-one/hype.md diff --git a/cmd/hype/cli/testdata/whole/simple/02-two/module.md b/cmd/hype/cli/testdata/whole/simple/02-two/hype.md similarity index 100% rename from cmd/hype/cli/testdata/whole/simple/02-two/module.md rename to cmd/hype/cli/testdata/whole/simple/02-two/hype.md diff --git a/cmd/hype/cli/testdata/whole/simple/03-three/module.md b/cmd/hype/cli/testdata/whole/simple/03-three/hype.md similarity index 100% rename from cmd/hype/cli/testdata/whole/simple/03-three/module.md rename to cmd/hype/cli/testdata/whole/simple/03-three/hype.md diff --git a/document_test.go b/document_test.go index 60d46da..ce2f060 100644 --- a/document_test.go +++ b/document_test.go @@ -18,7 +18,7 @@ func Test_Document_Execute(t *testing.T) { r := require.New(t) p := testParser(t, "testdata/doc/execution/success") - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) @@ -39,7 +39,7 @@ func Test_Document_Execute(t *testing.T) { r := require.New(t) p := testParser(t, "testdata/doc/execution/failure") - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) @@ -67,7 +67,7 @@ func Test_Document_MD(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) defer cancel() - doc, err := p.ParseExecuteFile(ctx, "module.md") + doc, err := p.ParseExecuteFile(ctx, "hype.md") r.NoError(err) s := doc.MD() @@ -76,7 +76,7 @@ func Test_Document_MD(t *testing.T) { // fmt.Println(act) - b, err := fs.ReadFile(p.FS, "module.gold") + b, err := fs.ReadFile(p.FS, "hype.gold") r.NoError(err) exp := string(b) @@ -96,7 +96,7 @@ func Test_Document_MarshalJSON(t *testing.T) { ctx := context.Background() - doc, err := p.ParseExecuteFile(ctx, "module.md") + doc, err := p.ParseExecuteFile(ctx, "hype.md") r.NoError(err) testJSON(t, "document", doc) @@ -108,7 +108,7 @@ func Test_Document_Pages(t *testing.T) { p := testParser(t, "testdata/doc/pages") - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) pages, err := doc.Pages() @@ -123,7 +123,7 @@ func Test_Document_Pages_NoPages(t *testing.T) { p := testParser(t, "testdata/doc/simple") - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) pages, err := doc.Pages() diff --git a/execute_error_test.go b/execute_error_test.go index 303d23e..a6a4610 100644 --- a/execute_error_test.go +++ b/execute_error_test.go @@ -72,7 +72,7 @@ func Test_Execute_Errors(t *testing.T) { name: "ParseExecuteFile", in: func() error { p := tp() - _, err := p.ParseExecuteFile(ctx, "module.md") + _, err := p.ParseExecuteFile(ctx, "hype.md") return err }, }, @@ -80,7 +80,7 @@ func Test_Execute_Errors(t *testing.T) { name: "Document.Execute", in: func() error { p := tp() - d, err := p.ParseFile("module.md") + d, err := p.ParseFile("hype.md") if err != nil { return err } @@ -114,7 +114,7 @@ func Test_ExecuteError_MarshalJSON(t *testing.T) { ee := ExecuteError{ Err: io.EOF, - Filename: "module.md", + Filename: "hype.md", Root: "testdata/parser/errors/execute", Document: &Document{ Title: "My Title", diff --git a/finders_test.go b/finders_test.go index 2e77003..d456ba2 100644 --- a/finders_test.go +++ b/finders_test.go @@ -26,7 +26,7 @@ and finally: ` cab := &fstest.MapFS{ - "module.md": &fstest.MapFile{ + "hype.md": &fstest.MapFile{ Data: []byte(mod), }, } @@ -39,7 +39,7 @@ func byXYZDoc(t testing.TB) *Document { p := NewParser(byXYZCab(t)) - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") if err != nil { t.Fatal(err) } diff --git a/hype_test.go b/hype_test.go index 57cbf9b..08ac33a 100644 --- a/hype_test.go +++ b/hype_test.go @@ -48,14 +48,14 @@ func testModule(t testing.TB, root string) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - doc, err := p.ParseExecuteFile(ctx, "module.md") + doc, err := p.ParseExecuteFile(ctx, "hype.md") r.NoError(err) act := doc.String() // fmt.Println(act) - b, err := fs.ReadFile(p.FS, "module.gold") + b, err := fs.ReadFile(p.FS, "hype.gold") r.NoError(err) exp := string(b) @@ -124,7 +124,7 @@ func Test_Testdata_Auto_Modules(t *testing.T) { } base := filepath.Base(path) - if base != "module.md" { + if base != "hype.md" { return nil } diff --git a/include_test.go b/include_test.go index 24fb5e5..8cfff0d 100644 --- a/include_test.go +++ b/include_test.go @@ -18,7 +18,7 @@ func Test_Include_Parse_Errors(t *testing.T) { }{ { root: "testdata/includes/broken", - filename: "module.md", + filename: "hype.md", }, } @@ -29,7 +29,7 @@ func Test_Include_Parse_Errors(t *testing.T) { ctx := context.Background() - _, err := p.ParseExecuteFile(ctx, "module.md") + _, err := p.ParseExecuteFile(ctx, "hype.md") r.Error(err) var ee ParseError @@ -52,7 +52,7 @@ func Test_Include_Cmd_Errors(t *testing.T) { }{ { root: "testdata/includes/toplevel", - filename: "module.md", + filename: "hype.md", }, { root: "testdata/includes/sublevel", @@ -67,7 +67,7 @@ func Test_Include_Cmd_Errors(t *testing.T) { ctx := context.Background() - _, err := p.ParseExecuteFile(ctx, "module.md") + _, err := p.ParseExecuteFile(ctx, "hype.md") r.Error(err) var ee ExecuteError @@ -99,7 +99,7 @@ func Test_Include(t *testing.T) { ` cab := fstest.MapFS{ - "module.md": &fstest.MapFile{ + "hype.md": &fstest.MapFile{ Data: []byte(mod), }, "second/second.md": &fstest.MapFile{ @@ -110,7 +110,7 @@ func Test_Include(t *testing.T) { p := NewParser(cab) - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) r.NotNil(doc) @@ -150,7 +150,7 @@ func Test_Include_Nested(t *testing.T) { ` cab := fstest.MapFS{ - "module.md": &fstest.MapFile{ + "hype.md": &fstest.MapFile{ Data: []byte(mod), }, "second/second.md": &fstest.MapFile{ @@ -165,7 +165,7 @@ func Test_Include_Nested(t *testing.T) { p := NewParser(cab) - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) r.NotNil(doc) diff --git a/md_test.go b/md_test.go index d081869..c10ede2 100644 --- a/md_test.go +++ b/md_test.go @@ -23,7 +23,7 @@ func Test_Markdown_UnknownAtom(t *testing.T) { ctx, cancel := context.WithTimeout(ctx, time.Second) defer cancel() - doc, err := p.ParseExecuteFile(ctx, "module.md") + doc, err := p.ParseExecuteFile(ctx, "hype.md") r.NoError(err) exp := `io.EOF` diff --git a/mdx/parser_test.go b/mdx/parser_test.go index b8854e5..28e0ba0 100644 --- a/mdx/parser_test.go +++ b/mdx/parser_test.go @@ -34,7 +34,7 @@ func Test_Parser_Parse(t *testing.T) { t.Parallel() r := require.New(t) - src, err := fs.ReadFile(testdata, "module.md") + src, err := fs.ReadFile(testdata, "hype.md") r.NoError(err) p := New() diff --git a/mdx/testdata/module.md b/mdx/testdata/hype.md similarity index 100% rename from mdx/testdata/module.md rename to mdx/testdata/hype.md diff --git a/metadata_test.go b/metadata_test.go index e9eaa60..e0004c0 100644 --- a/metadata_test.go +++ b/metadata_test.go @@ -16,7 +16,7 @@ func Test_NewMetadata_Pages(t *testing.T) { cab := os.DirFS("testdata/metadata/pages") p := NewParser(cab) - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) mds := ByType[*Metadata](doc.Children()) @@ -49,7 +49,7 @@ func Test_NewMetadata_Multiple_Erro0r(t *testing.T) { cab := os.DirFS("testdata/metadata/multi") p := NewParser(cab) - _, err := p.ParseFile("module.md") + _, err := p.ParseFile("hype.md") r.Error(err) r.True(errors.Is(err, ParseError{})) diff --git a/now_test.go b/now_test.go index febab7a..3f8385f 100644 --- a/now_test.go +++ b/now_test.go @@ -27,7 +27,7 @@ func Test_NowNodes(t *testing.T) { defer cancel() - doc, err := p.ParseExecuteFile(ctx, "module.md") + doc, err := p.ParseExecuteFile(ctx, "hype.md") r.NoError(err) act := doc.String() @@ -35,7 +35,7 @@ func Test_NowNodes(t *testing.T) { // fmt.Println(act) - b, err := fs.ReadFile(p.FS, "module.gold") + b, err := fs.ReadFile(p.FS, "hype.gold") r.NoError(err) exp := string(b) diff --git a/page_test.go b/page_test.go index c873983..c4d8b8a 100644 --- a/page_test.go +++ b/page_test.go @@ -23,7 +23,7 @@ more text adfadf` cab := fstest.MapFS{ - "module.md": &fstest.MapFile{ + "hype.md": &fstest.MapFile{ Data: []byte(mod), }, "second/second.md": &fstest.MapFile{ diff --git a/parser.go b/parser.go index 9750003..9ab9d0a 100644 --- a/parser.go +++ b/parser.go @@ -213,7 +213,7 @@ func (p *Parser) ParseFolder(name string) (doc Documents, err error) { base := filepath.Base(path) - if base != "module.md" { + if base != "hype.md" { return nil } diff --git a/parser_test.go b/parser_test.go index 9084d2c..ab3ab6f 100644 --- a/parser_test.go +++ b/parser_test.go @@ -140,7 +140,7 @@ func Test_Parser_MarshalJSON(t *testing.T) { err := p.Vars.Set("foo", "bar") r.NoError(err) - _, err = p.ParseFile("module.md") + _, err = p.ParseFile("hype.md") r.NoError(err) testJSON(t, "parser", p) diff --git a/post_execute_error_test.go b/post_execute_error_test.go index 992588d..0f40c26 100644 --- a/post_execute_error_test.go +++ b/post_execute_error_test.go @@ -63,7 +63,7 @@ func Test_PostExecute_Errors(t *testing.T) { name: "ParseExecuteFile", in: func() error { p := tp() - _, err := p.ParseExecuteFile(ctx, "module.md") + _, err := p.ParseExecuteFile(ctx, "hype.md") return err }, }, diff --git a/post_parse_error_test.go b/post_parse_error_test.go index 454db9f..29e4f7f 100644 --- a/post_parse_error_test.go +++ b/post_parse_error_test.go @@ -64,7 +64,7 @@ func Test_PostParser_Errors(t *testing.T) { name: "ParseFile", in: func() error { p := tp() - _, err := p.ParseFile("module.md") + _, err := p.ParseFile("hype.md") return err }, }, @@ -72,7 +72,7 @@ func Test_PostParser_Errors(t *testing.T) { name: "ParseExecuteFile", in: func() error { p := tp() - _, err := p.ParseExecuteFile(ctx, "module.md") + _, err := p.ParseExecuteFile(ctx, "hype.md") return err }, }, diff --git a/post_parser_test.go b/post_parser_test.go index d3cce63..8ad64b2 100644 --- a/post_parser_test.go +++ b/post_parser_test.go @@ -78,7 +78,7 @@ func Test_PostParsers_PostParse_Errors(t *testing.T) { d := &Document{} p := testParser(t, "testdata/whole/simple") - p.Filename = "module.md" + p.Filename = "hype.md" err := nodes.PostParse(p, d, fmt.Errorf("original")) r.Error(err) diff --git a/pre_execute_error_test.go b/pre_execute_error_test.go index 4051e33..53a1dd8 100644 --- a/pre_execute_error_test.go +++ b/pre_execute_error_test.go @@ -64,7 +64,7 @@ func Test_PreExecute_Errors(t *testing.T) { name: "ParseExecuteFile", in: func() error { p := tp() - _, err := p.ParseExecuteFile(ctx, "module.md") + _, err := p.ParseExecuteFile(ctx, "hype.md") return err }, }, @@ -106,7 +106,7 @@ func Test_PreExecuteError_MarshalJSON(t *testing.T) { pee := PreExecuteError{ Err: io.EOF, - Filename: "module.md", + Filename: "hype.md", Root: "root", Document: &Document{ Title: "My Title", diff --git a/pre_parse_error_test.go b/pre_parse_error_test.go index 304ecaf..16c1185 100644 --- a/pre_parse_error_test.go +++ b/pre_parse_error_test.go @@ -61,14 +61,14 @@ func Test_PreParser_Errors(t *testing.T) { { name: "ParseFile", in: func() error { - _, err := tp().ParseFile("module.md") + _, err := tp().ParseFile("hype.md") return err }, }, { name: "ParseExecuteFile", in: func() error { - _, err := tp().ParseExecuteFile(ctx, "module.md") + _, err := tp().ParseExecuteFile(ctx, "hype.md") return err }, }, @@ -123,7 +123,7 @@ func Test_PreParseError_MarshalJSON(t *testing.T) { ppe := PreParseError{ Err: io.EOF, - Filename: "module.md", + Filename: "hype.md", Root: "root", } diff --git a/ref_processor_test.go b/ref_processor_test.go index 970e702..a7366c9 100644 --- a/ref_processor_test.go +++ b/ref_processor_test.go @@ -20,7 +20,7 @@ func Test_RefProcessor_Process(t *testing.T) { ctx := context.Background() - doc, err := p.ParseExecuteFile(ctx, "module.md") + doc, err := p.ParseExecuteFile(ctx, "hype.md") r.NoError(err) rp := &RefProcessor{} @@ -28,7 +28,7 @@ func Test_RefProcessor_Process(t *testing.T) { err = rp.Process(doc) r.NoError(err) - b, err := fs.ReadFile(cab, "module.gold") + b, err := fs.ReadFile(cab, "hype.gold") r.NoError(err) exp := string(b) diff --git a/table_test.go b/table_test.go index a930a9b..3f15f62 100644 --- a/table_test.go +++ b/table_test.go @@ -14,7 +14,7 @@ func Test_Table_Data(t *testing.T) { root := "testdata/table/data" p := testParser(t, root) - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) // fmt.Println(doc.String()) @@ -77,7 +77,7 @@ func Test_Table_MarshalJSON(t *testing.T) { p := testParser(t, "testdata/table/data") - doc, err := p.ParseFile("module.md") + doc, err := p.ParseFile("hype.md") r.NoError(err) tables := ByType[*Table](doc.Children()) diff --git a/testdata/auto/blockquote/html/module.gold b/testdata/auto/blockquote/html/hype.gold similarity index 100% rename from testdata/auto/blockquote/html/module.gold rename to testdata/auto/blockquote/html/hype.gold diff --git a/testdata/auto/blockquote/html/module.md b/testdata/auto/blockquote/html/hype.md similarity index 100% rename from testdata/auto/blockquote/html/module.md rename to testdata/auto/blockquote/html/hype.md diff --git a/testdata/auto/blockquote/md/module.gold b/testdata/auto/blockquote/md/hype.gold similarity index 100% rename from testdata/auto/blockquote/md/module.gold rename to testdata/auto/blockquote/md/hype.gold diff --git a/testdata/auto/blockquote/md/module.md b/testdata/auto/blockquote/md/hype.md similarity index 100% rename from testdata/auto/blockquote/md/module.md rename to testdata/auto/blockquote/md/hype.md diff --git a/testdata/auto/commands/greet/module.gold b/testdata/auto/commands/greet/hype.gold similarity index 100% rename from testdata/auto/commands/greet/module.gold rename to testdata/auto/commands/greet/hype.gold diff --git a/testdata/auto/commands/greet/module.md b/testdata/auto/commands/greet/hype.md similarity index 100% rename from testdata/auto/commands/greet/module.md rename to testdata/auto/commands/greet/hype.md diff --git a/testdata/auto/commands/results/data/module.gold b/testdata/auto/commands/results/data/hype.gold similarity index 100% rename from testdata/auto/commands/results/data/module.gold rename to testdata/auto/commands/results/data/hype.gold diff --git a/testdata/auto/commands/results/data/module.md b/testdata/auto/commands/results/data/hype.md similarity index 100% rename from testdata/auto/commands/results/data/module.md rename to testdata/auto/commands/results/data/hype.md diff --git a/testdata/auto/commands/results/truncate/module.gold b/testdata/auto/commands/results/truncate/hype.gold similarity index 100% rename from testdata/auto/commands/results/truncate/module.gold rename to testdata/auto/commands/results/truncate/hype.gold diff --git a/testdata/auto/commands/results/truncate/module.md b/testdata/auto/commands/results/truncate/hype.md similarity index 100% rename from testdata/auto/commands/results/truncate/module.md rename to testdata/auto/commands/results/truncate/hype.md diff --git a/testdata/auto/commands/side-by-side/module.gold b/testdata/auto/commands/side-by-side/hype.gold similarity index 100% rename from testdata/auto/commands/side-by-side/module.gold rename to testdata/auto/commands/side-by-side/hype.gold diff --git a/testdata/auto/commands/side-by-side/module.md b/testdata/auto/commands/side-by-side/hype.md similarity index 100% rename from testdata/auto/commands/side-by-side/module.md rename to testdata/auto/commands/side-by-side/hype.md diff --git a/testdata/auto/metadata/simple/module.gold b/testdata/auto/metadata/simple/hype.gold similarity index 100% rename from testdata/auto/metadata/simple/module.gold rename to testdata/auto/metadata/simple/hype.gold diff --git a/testdata/auto/metadata/simple/module.md b/testdata/auto/metadata/simple/hype.md similarity index 100% rename from testdata/auto/metadata/simple/module.md rename to testdata/auto/metadata/simple/hype.md diff --git a/testdata/auto/parser/hello/module.gold b/testdata/auto/parser/hello/hype.gold similarity index 100% rename from testdata/auto/parser/hello/module.gold rename to testdata/auto/parser/hello/hype.gold diff --git a/testdata/auto/parser/hello/module.md b/testdata/auto/parser/hello/hype.md similarity index 100% rename from testdata/auto/parser/hello/module.md rename to testdata/auto/parser/hello/hype.md diff --git a/testdata/auto/refs/fenced/module.gold b/testdata/auto/refs/fenced/hype.gold similarity index 100% rename from testdata/auto/refs/fenced/module.gold rename to testdata/auto/refs/fenced/hype.gold diff --git a/testdata/auto/refs/fenced/module.md b/testdata/auto/refs/fenced/hype.md similarity index 100% rename from testdata/auto/refs/fenced/module.md rename to testdata/auto/refs/fenced/hype.md diff --git a/testdata/auto/refs/figure-styles/module.gold b/testdata/auto/refs/figure-styles/hype.gold similarity index 100% rename from testdata/auto/refs/figure-styles/module.gold rename to testdata/auto/refs/figure-styles/hype.gold diff --git a/testdata/auto/refs/figure-styles/module.md b/testdata/auto/refs/figure-styles/hype.md similarity index 100% rename from testdata/auto/refs/figure-styles/module.md rename to testdata/auto/refs/figure-styles/hype.md diff --git a/testdata/auto/refs/images/module.gold b/testdata/auto/refs/images/hype.gold similarity index 100% rename from testdata/auto/refs/images/module.gold rename to testdata/auto/refs/images/hype.gold diff --git a/testdata/auto/refs/images/module.md b/testdata/auto/refs/images/hype.md similarity index 100% rename from testdata/auto/refs/images/module.md rename to testdata/auto/refs/images/hype.md diff --git a/testdata/auto/refs/includes/module.gold b/testdata/auto/refs/includes/hype.gold similarity index 100% rename from testdata/auto/refs/includes/module.gold rename to testdata/auto/refs/includes/hype.gold diff --git a/testdata/auto/refs/includes/module.md b/testdata/auto/refs/includes/hype.md similarity index 100% rename from testdata/auto/refs/includes/module.md rename to testdata/auto/refs/includes/hype.md diff --git a/testdata/auto/refs/simple/module.gold b/testdata/auto/refs/simple/hype.gold similarity index 100% rename from testdata/auto/refs/simple/module.gold rename to testdata/auto/refs/simple/hype.gold diff --git a/testdata/auto/refs/simple/module.md b/testdata/auto/refs/simple/hype.md similarity index 100% rename from testdata/auto/refs/simple/module.md rename to testdata/auto/refs/simple/hype.md diff --git a/testdata/auto/snippets/range/module.gold b/testdata/auto/snippets/range/hype.gold similarity index 100% rename from testdata/auto/snippets/range/module.gold rename to testdata/auto/snippets/range/hype.gold diff --git a/testdata/auto/snippets/range/module.md b/testdata/auto/snippets/range/hype.md similarity index 100% rename from testdata/auto/snippets/range/module.md rename to testdata/auto/snippets/range/hype.md diff --git a/testdata/auto/snippets/simple/module.gold b/testdata/auto/snippets/simple/hype.gold similarity index 100% rename from testdata/auto/snippets/simple/module.gold rename to testdata/auto/snippets/simple/hype.gold diff --git a/testdata/auto/snippets/simple/module.md b/testdata/auto/snippets/simple/hype.md similarity index 100% rename from testdata/auto/snippets/simple/module.md rename to testdata/auto/snippets/simple/hype.md diff --git a/testdata/auto/toc/module.gold b/testdata/auto/toc/hype.gold similarity index 100% rename from testdata/auto/toc/module.gold rename to testdata/auto/toc/hype.gold diff --git a/testdata/auto/toc/module.md b/testdata/auto/toc/hype.md similarity index 100% rename from testdata/auto/toc/module.md rename to testdata/auto/toc/hype.md diff --git a/testdata/auto/vars/details/module.gold b/testdata/auto/vars/details/hype.gold similarity index 100% rename from testdata/auto/vars/details/module.gold rename to testdata/auto/vars/details/hype.gold diff --git a/testdata/auto/vars/details/module.md b/testdata/auto/vars/details/hype.md similarity index 100% rename from testdata/auto/vars/details/module.md rename to testdata/auto/vars/details/hype.md diff --git a/testdata/auto/vars/metadata/module.gold b/testdata/auto/vars/metadata/hype.gold similarity index 100% rename from testdata/auto/vars/metadata/module.gold rename to testdata/auto/vars/metadata/hype.gold diff --git a/testdata/auto/vars/metadata/module.md b/testdata/auto/vars/metadata/hype.md similarity index 100% rename from testdata/auto/vars/metadata/module.md rename to testdata/auto/vars/metadata/hype.md diff --git a/testdata/auto/vars/var_tag/module.gold b/testdata/auto/vars/var_tag/hype.gold similarity index 100% rename from testdata/auto/vars/var_tag/module.gold rename to testdata/auto/vars/var_tag/hype.gold diff --git a/testdata/auto/vars/var_tag/module.md b/testdata/auto/vars/var_tag/hype.md similarity index 100% rename from testdata/auto/vars/var_tag/module.md rename to testdata/auto/vars/var_tag/hype.md diff --git a/testdata/doc/execution/failure/module.md b/testdata/doc/execution/failure/hype.md similarity index 100% rename from testdata/doc/execution/failure/module.md rename to testdata/doc/execution/failure/hype.md diff --git a/testdata/doc/execution/nested_failure/module.md b/testdata/doc/execution/nested_failure/hype.md similarity index 100% rename from testdata/doc/execution/nested_failure/module.md rename to testdata/doc/execution/nested_failure/hype.md diff --git a/testdata/doc/execution/success/module.md b/testdata/doc/execution/success/hype.md similarity index 100% rename from testdata/doc/execution/success/module.md rename to testdata/doc/execution/success/hype.md diff --git a/testdata/doc/pages/module.md b/testdata/doc/pages/hype.md similarity index 100% rename from testdata/doc/pages/module.md rename to testdata/doc/pages/hype.md diff --git a/testdata/doc/simple/module.md b/testdata/doc/simple/hype.md similarity index 100% rename from testdata/doc/simple/module.md rename to testdata/doc/simple/hype.md diff --git a/testdata/doc/snippets/module.md b/testdata/doc/snippets/hype.md similarity index 100% rename from testdata/doc/snippets/module.md rename to testdata/doc/snippets/hype.md diff --git a/testdata/doc/to_md/module.gold b/testdata/doc/to_md/hype.gold similarity index 100% rename from testdata/doc/to_md/module.gold rename to testdata/doc/to_md/hype.gold diff --git a/testdata/doc/to_md/module.md b/testdata/doc/to_md/hype.md similarity index 100% rename from testdata/doc/to_md/module.md rename to testdata/doc/to_md/hype.md diff --git a/testdata/includes/broken/module.md b/testdata/includes/broken/hype.md similarity index 100% rename from testdata/includes/broken/module.md rename to testdata/includes/broken/hype.md diff --git a/testdata/includes/sublevel/module.md b/testdata/includes/sublevel/hype.md similarity index 100% rename from testdata/includes/sublevel/module.md rename to testdata/includes/sublevel/hype.md diff --git a/testdata/includes/toplevel/module.md b/testdata/includes/toplevel/hype.md similarity index 100% rename from testdata/includes/toplevel/module.md rename to testdata/includes/toplevel/hype.md diff --git a/testdata/json/document.json b/testdata/json/document.json index f05bec4..b6b50ce 100644 --- a/testdata/json/document.json +++ b/testdata/json/document.json @@ -1,11 +1,11 @@ { - "filename": "module.md", + "filename": "hype.md", "id": "1", "nodes": [ { "atom": "", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "", "data_atom": "", @@ -17,7 +17,7 @@ { "atom": "html", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "html", "data_atom": "html", @@ -29,7 +29,7 @@ { "atom": "head", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "head", "data_atom": "head", @@ -45,7 +45,7 @@ { "atom": "body", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "body", "data_atom": "body", @@ -58,7 +58,7 @@ { "atom": "page", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "page", "data_atom": "", @@ -75,7 +75,7 @@ { "atom": "h1", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "h1", "data_atom": "h1", @@ -102,7 +102,7 @@ { "atom": "pre", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "pre", "data_atom": "pre", @@ -119,7 +119,7 @@ "snippet": "class", "src": "src/main.ts" }, - "filename": "module.md", + "filename": "hype.md", "html_node": { "attributes": [ { @@ -166,7 +166,7 @@ { "atom": "pre", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "pre", "data_atom": "pre", @@ -183,7 +183,7 @@ "snippet": "constructor", "src": "src/main.ts" }, - "filename": "module.md", + "filename": "hype.md", "html_node": { "attributes": [ { diff --git a/testdata/json/execute_error.json b/testdata/json/execute_error.json index 6023c86..d792d01 100644 --- a/testdata/json/execute_error.json +++ b/testdata/json/execute_error.json @@ -6,7 +6,7 @@ "type": "hype.Document" }, "error": "EOF", - "filename": "module.md", + "filename": "hype.md", "root": "testdata/parser/errors/execute", "type": "hype.ExecuteError" } \ No newline at end of file diff --git a/testdata/json/pre_execute_error.json b/testdata/json/pre_execute_error.json index 2e194fc..1c4ca16 100644 --- a/testdata/json/pre_execute_error.json +++ b/testdata/json/pre_execute_error.json @@ -5,7 +5,7 @@ "type": "hype.Document" }, "error": "EOF", - "filename": "module.md", + "filename": "hype.md", "pre_executer": "\u003cnil\u003e", "root": "root", "type": "hype.PreExecuteError" diff --git a/testdata/json/pre_parse_error.json b/testdata/json/pre_parse_error.json index 36c482c..dc21cc1 100644 --- a/testdata/json/pre_parse_error.json +++ b/testdata/json/pre_parse_error.json @@ -1,7 +1,7 @@ { "contents": "", "error": "EOF", - "filename": "module.md", + "filename": "hype.md", "pre_parser": "\u003cnil\u003e", "root": "root", "type": "hype.PreParseError" diff --git a/testdata/json/table.json b/testdata/json/table.json index 4651443..400dd73 100644 --- a/testdata/json/table.json +++ b/testdata/json/table.json @@ -1,7 +1,7 @@ { "atom": "table", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "table", "data_atom": "table", @@ -18,7 +18,7 @@ { "atom": "thead", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "thead", "data_atom": "thead", @@ -35,7 +35,7 @@ { "atom": "tr", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "tr", "data_atom": "tr", @@ -52,7 +52,7 @@ { "atom": "th", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "th", "data_atom": "th", @@ -78,7 +78,7 @@ { "atom": "th", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "th", "data_atom": "th", @@ -121,7 +121,7 @@ { "atom": "tbody", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "tbody", "data_atom": "tbody", @@ -138,7 +138,7 @@ { "atom": "tr", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "tr", "data_atom": "tr", @@ -155,7 +155,7 @@ { "atom": "td", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "td", "data_atom": "td", @@ -181,7 +181,7 @@ { "atom": "td", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "td", "data_atom": "td", @@ -216,7 +216,7 @@ { "atom": "tr", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "tr", "data_atom": "tr", @@ -233,7 +233,7 @@ { "atom": "td", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "td", "data_atom": "td", @@ -259,7 +259,7 @@ { "atom": "td", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "td", "data_atom": "td", @@ -294,7 +294,7 @@ { "atom": "tr", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "tr", "data_atom": "tr", @@ -311,7 +311,7 @@ { "atom": "td", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "td", "data_atom": "td", @@ -337,7 +337,7 @@ { "atom": "td", "attributes": {}, - "filename": "module.md", + "filename": "hype.md", "html_node": { "data": "td", "data_atom": "td", diff --git a/testdata/markdown/unknown-atom/module.md b/testdata/markdown/unknown-atom/hype.md similarity index 100% rename from testdata/markdown/unknown-atom/module.md rename to testdata/markdown/unknown-atom/hype.md diff --git a/testdata/metadata/multi/module.md b/testdata/metadata/multi/hype.md similarity index 100% rename from testdata/metadata/multi/module.md rename to testdata/metadata/multi/hype.md diff --git a/testdata/metadata/pages/module.md b/testdata/metadata/pages/hype.md similarity index 100% rename from testdata/metadata/pages/module.md rename to testdata/metadata/pages/hype.md diff --git a/testdata/now/module.gold b/testdata/now/hype.gold similarity index 100% rename from testdata/now/module.gold rename to testdata/now/hype.gold diff --git a/testdata/now/module.md b/testdata/now/hype.md similarity index 100% rename from testdata/now/module.md rename to testdata/now/hype.md diff --git a/testdata/parser/errors/execute/module.md b/testdata/parser/errors/execute/hype.md similarity index 100% rename from testdata/parser/errors/execute/module.md rename to testdata/parser/errors/execute/hype.md diff --git a/testdata/parser/errors/folder/01-one/module.md b/testdata/parser/errors/folder/01-one/hype.md similarity index 100% rename from testdata/parser/errors/folder/01-one/module.md rename to testdata/parser/errors/folder/01-one/hype.md diff --git a/testdata/parser/errors/folder/01-one/module.tex.gold b/testdata/parser/errors/folder/01-one/hype.tex.gold similarity index 100% rename from testdata/parser/errors/folder/01-one/module.tex.gold rename to testdata/parser/errors/folder/01-one/hype.tex.gold diff --git a/testdata/parser/errors/folder/02-two/module.md b/testdata/parser/errors/folder/02-two/hype.md similarity index 100% rename from testdata/parser/errors/folder/02-two/module.md rename to testdata/parser/errors/folder/02-two/hype.md diff --git a/testdata/parser/errors/folder/02-two/module.tex.gold b/testdata/parser/errors/folder/02-two/hype.tex.gold similarity index 100% rename from testdata/parser/errors/folder/02-two/module.tex.gold rename to testdata/parser/errors/folder/02-two/hype.tex.gold diff --git a/testdata/parser/errors/folder/03-three/module.md b/testdata/parser/errors/folder/03-three/hype.md similarity index 100% rename from testdata/parser/errors/folder/03-three/module.md rename to testdata/parser/errors/folder/03-three/hype.md diff --git a/testdata/parser/errors/folder/03-three/module.tex.gold b/testdata/parser/errors/folder/03-three/hype.tex.gold similarity index 100% rename from testdata/parser/errors/folder/03-three/module.tex.gold rename to testdata/parser/errors/folder/03-three/hype.tex.gold diff --git a/testdata/parser/errors/post_execute/module.md b/testdata/parser/errors/post_execute/hype.md similarity index 100% rename from testdata/parser/errors/post_execute/module.md rename to testdata/parser/errors/post_execute/hype.md diff --git a/testdata/parser/errors/post_parse/module.md b/testdata/parser/errors/post_parse/hype.md similarity index 100% rename from testdata/parser/errors/post_parse/module.md rename to testdata/parser/errors/post_parse/hype.md diff --git a/testdata/parser/errors/pre_execute/module.md b/testdata/parser/errors/pre_execute/hype.md similarity index 100% rename from testdata/parser/errors/pre_execute/module.md rename to testdata/parser/errors/pre_execute/hype.md diff --git a/testdata/parser/errors/pre_parse/module.md b/testdata/parser/errors/pre_parse/hype.md similarity index 100% rename from testdata/parser/errors/pre_parse/module.md rename to testdata/parser/errors/pre_parse/hype.md diff --git a/testdata/parser/folder/01-one/module.md b/testdata/parser/folder/01-one/hype.md similarity index 100% rename from testdata/parser/folder/01-one/module.md rename to testdata/parser/folder/01-one/hype.md diff --git a/testdata/parser/folder/01-one/module.tex.gold b/testdata/parser/folder/01-one/hype.tex.gold similarity index 100% rename from testdata/parser/folder/01-one/module.tex.gold rename to testdata/parser/folder/01-one/hype.tex.gold diff --git a/testdata/parser/folder/02-two/module.md b/testdata/parser/folder/02-two/hype.md similarity index 100% rename from testdata/parser/folder/02-two/module.md rename to testdata/parser/folder/02-two/hype.md diff --git a/testdata/parser/folder/02-two/module.tex.gold b/testdata/parser/folder/02-two/hype.tex.gold similarity index 100% rename from testdata/parser/folder/02-two/module.tex.gold rename to testdata/parser/folder/02-two/hype.tex.gold diff --git a/testdata/parser/folder/03-three/module.md b/testdata/parser/folder/03-three/hype.md similarity index 100% rename from testdata/parser/folder/03-three/module.md rename to testdata/parser/folder/03-three/hype.md diff --git a/testdata/parser/folder/03-three/module.tex.gold b/testdata/parser/folder/03-three/hype.tex.gold similarity index 100% rename from testdata/parser/folder/03-three/module.tex.gold rename to testdata/parser/folder/03-three/hype.tex.gold diff --git a/testdata/table/data/module.md b/testdata/table/data/hype.md similarity index 100% rename from testdata/table/data/module.md rename to testdata/table/data/hype.md diff --git a/testdata/table/headless/module.gold b/testdata/table/headless/hype.gold similarity index 100% rename from testdata/table/headless/module.gold rename to testdata/table/headless/hype.gold diff --git a/testdata/table/headless/module.md b/testdata/table/headless/hype.md similarity index 100% rename from testdata/table/headless/module.md rename to testdata/table/headless/hype.md diff --git a/testdata/table/md_in_html/module.gold b/testdata/table/md_in_html/hype.gold similarity index 100% rename from testdata/table/md_in_html/module.gold rename to testdata/table/md_in_html/hype.gold diff --git a/testdata/table/md_in_html/module.md b/testdata/table/md_in_html/hype.md similarity index 100% rename from testdata/table/md_in_html/module.md rename to testdata/table/md_in_html/hype.md diff --git a/testdata/table/md_in_md/module.gold b/testdata/table/md_in_md/hype.gold similarity index 100% rename from testdata/table/md_in_md/module.gold rename to testdata/table/md_in_md/hype.gold diff --git a/testdata/table/md_in_md/module.md b/testdata/table/md_in_md/hype.md similarity index 100% rename from testdata/table/md_in_md/module.md rename to testdata/table/md_in_md/hype.md diff --git a/testdata/toc/module.gold b/testdata/toc/hype.gold similarity index 100% rename from testdata/toc/module.gold rename to testdata/toc/hype.gold diff --git a/testdata/toc/module.md b/testdata/toc/hype.md similarity index 100% rename from testdata/toc/module.md rename to testdata/toc/hype.md diff --git a/tmpl_test.go b/tmpl_test.go index 4e4590f..0e77609 100644 --- a/tmpl_test.go +++ b/tmpl_test.go @@ -20,7 +20,7 @@ func Test_GoTemplates(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - doc, err := p.ParseExecuteFile(ctx, "module.md") + doc, err := p.ParseExecuteFile(ctx, "hype.md") r.NoError(err) act := doc.String() diff --git a/toc_test.go b/toc_test.go index a46e182..53edc83 100644 --- a/toc_test.go +++ b/toc_test.go @@ -21,7 +21,7 @@ func Test_GenerateToC(t *testing.T) { ctx, cancel := context.WithTimeout(ctx, time.Second) defer cancel() - doc, err := p.ParseExecuteFile(ctx, "module.md") + doc, err := p.ParseExecuteFile(ctx, "hype.md") r.NoError(err) toc, err := GenerateToC(p, doc.Children()) @@ -29,7 +29,7 @@ func Test_GenerateToC(t *testing.T) { r.Len(toc, 1) - b, err := fs.ReadFile(p.FS, "module.gold") + b, err := fs.ReadFile(p.FS, "hype.gold") r.NoError(err) exp := string(b) From 701da52b247172c5685bb34e404fae858a7ff947 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Thu, 29 Feb 2024 13:34:07 -0500 Subject: [PATCH 02/14] more renaming --- .hype/{module.md => hype.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .hype/{module.md => hype.md} (100%) diff --git a/.hype/module.md b/.hype/hype.md similarity index 100% rename from .hype/module.md rename to .hype/hype.md From 1326e2863d3598483a99a5b1e237f43cd2a334e1 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Thu, 29 Feb 2024 13:36:15 -0500 Subject: [PATCH 03/14] more renaming --- .hype/actions/{module.md => hype.md} | 0 .hype/quickstart/{module.md => hype.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .hype/actions/{module.md => hype.md} (100%) rename .hype/quickstart/{module.md => hype.md} (100%) diff --git a/.hype/actions/module.md b/.hype/actions/hype.md similarity index 100% rename from .hype/actions/module.md rename to .hype/actions/hype.md diff --git a/.hype/quickstart/module.md b/.hype/quickstart/hype.md similarity index 100% rename from .hype/quickstart/module.md rename to .hype/quickstart/hype.md From e086cf1eb1186d8f89871cfe35416d164bff1201 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 29 Feb 2024 18:37:15 +0000 Subject: [PATCH 04/14] Updated README --- README.md | 62 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index f83f3d4..7d2d0a8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + [Release](https://github.com/gopherguides/hype/releases/latest) [Go Build Status](https://github.com/gopherguides/hype/actions) [Go Reference](https://pkg.go.dev/github.com/gopherguides/hype) @@ -12,11 +13,13 @@ Hype is a content generation tool that use traditional Markdown syntax, and allo Hype follows the same principals that we use for coding; -- packages (keep relevant content in small, reusable packages, with all links relative to the package) -- reuse - write your documentation once (even in your code), and use everywhere (blog, book, github repo, etc) -- partials/includes - support including documents into a larger document (just like code!) -- validation - like tests, but validate all your code samples are valid (or not if that is what you expect). -- asset validation - ensure local assets like images, etc actually exist + +* packages (keep relevant content in small, reusable packages, with all links relative to the package) +* reuse - write your documentation once (even in your code), and use everywhere (blog, book, github repo, etc) +* partials/includes - support including documents into a larger document (just like code!) +* validation - like tests, but validate all your code samples are valid (or not if that is what you expect). +* asset validation - ensure local assets like images, etc actually exist + ## Created with Hype @@ -45,8 +48,10 @@ This is the syntax to include a code sample in your document: The above code snippet does the following: -- Includes the code snippet specified in the source code -- Validates that the code compiles + +* Includes the code snippet specified in the source code +* Validates that the code compiles + Here is the source file: @@ -255,7 +260,6 @@ You can also be more specific. ` Here is the output for the above command: - ```shell $ go doc -short context.WithCancel @@ -288,8 +292,8 @@ Here is the output: $ tree . -├── includes.md ├── hype.md +├── includes.md └── src ├── broken │   └── main.go @@ -306,20 +310,20 @@ There are several options for running the `hype` command. Most notable is the `e `$ hype export -h Usage of hype: --f string -optional file name to preview, if not provided, defaults to hype.md (default "hype.md") --format string -content type to export to: markdown, html (default "markdown") --timeout duration -timeout for execution, defaults to 30 seconds (30s) (default 5s) --v enable verbose output for debugging + -f string + optional file name to preview, if not provided, defaults to hype.md (default "hype.md") + -format string + content type to export to: markdown, html (default "markdown") + -timeout duration + timeout for execution, defaults to 30 seconds (30s) (default 5s) + -v enable verbose output for debugging Usage: hype export [options] Examples: -hype export -format html -hype export -f README.md -format html -hype export -f README.md -format markdown -timeout=10s + hype export -format html + hype export -f README.md -format html + hype export -f README.md -format markdown -timeout=10s ` This allows you to see your compiled document either as a single markdown, or as an html document that you can preview in the browser. @@ -336,6 +340,7 @@ The following code will parse the code/code.md and sourceable/sourceable.md docu + ``` --- @@ -351,14 +356,14 @@ $ tree . ├── actions -│   ├── hype.yml -│   └── hype.md +│   ├── hype.md +│   └── hype.yml ├── badges.md -├── license.md ├── hype.md +├── license.md └── quickstart - ├── includes.md ├── hype.md + ├── includes.md └── src ├── broken │   └── main.go @@ -367,7 +372,6 @@ $ tree 5 directories, 9 files ``` - --- # Using Github Actions to update your README @@ -384,8 +388,10 @@ You need to give permission to your GitHub Actions to create a pull request in y Under `Workflow Permissions` -- Check `Allow GitHub Actions to create and approve pull requests`. -- Check `Read and write permissions` + +* Check `Allow GitHub Actions to create and approve pull requests`. +* Check `Read and write permissions` + ### Personal Access Token @@ -395,7 +401,7 @@ It is recommend to use a GitHub [Personnal Acces Token](https://docs.github.com/ ## The Action -The current action is set to only generate the readme on a pull request and commit it back to that same pull request. You can modify this to your own needs. +The current action is set to only generate the readme on a pull request and commit it back to that same pull request. You can modify this to your own needs. ```yml name: Generate README with Hype @@ -428,6 +434,7 @@ jobs: git config user.email 'actions@github.com' git diff --quiet || (git add README.md && git commit -am "Updated README") git push origin ${{github.event.pull_request.head.ref}} + ``` --- @@ -441,3 +448,4 @@ There are several issues that still need to be worked on. Please see the issues # License [Hype](https://github.com/gopherguides/hype) by [Gopher Guides LLC](https://github.com/gopherguides) is licensed under [Attribution-NonCommercial-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-nc-sa/4.0/?ref=chooser-v1) + From bef7c4f6ddc13067070c9d1d7c6a9b5d7ba3c811 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Fri, 8 Mar 2024 18:14:08 -0500 Subject: [PATCH 05/14] present better errors for marked --- cmd/hype/cli/marked.go | 1 + cmd_error.go | 30 +++++++++++++++++++++++++++- cmd_error_test.go | 27 ++++++++++++++++++++++++++ execute_error.go | 30 +++++++++++++++++++++++++++- execute_error_test.go | 43 +++++++++++++++++++++++++++++++++++++++++ go.mod | 10 +++++----- go.sum | 16 +++++++-------- parse_error.go | 22 ++++++++++++++++++++- parse_error_test.go | 23 ++++++++++++++++++++++ pre_parse_error.go | 26 ++++++++++++++++++++++++- pre_parse_error_test.go | 20 +++++++++++++++++++ 11 files changed, 231 insertions(+), 17 deletions(-) diff --git a/cmd/hype/cli/marked.go b/cmd/hype/cli/marked.go index 8f11bc5..8cec18c 100644 --- a/cmd/hype/cli/marked.go +++ b/cmd/hype/cli/marked.go @@ -204,6 +204,7 @@ func (cmd *Marked) execute(ctx context.Context, pwd string) error { } p.Root = filepath.Dir(mp) + p.Filename = filepath.Base(mp) if len(cmd.File) > 0 { f, err := cmd.FS.Open(cmd.File) diff --git a/cmd_error.go b/cmd_error.go index 2285365..13f5a70 100644 --- a/cmd_error.go +++ b/cmd_error.go @@ -2,6 +2,9 @@ package hype import ( "encoding/json" + "fmt" + "path/filepath" + "strings" "github.com/markbates/clam" ) @@ -26,7 +29,32 @@ func (ce CmdError) MarshalJSON() ([]byte, error) { } func (ce CmdError) Error() string { - return toError(ce) + sb := &strings.Builder{} + + var lines []string + + fp := filepath.Join(ce.Dir, ce.Filename) + if len(fp) > 0 { + lines = append(lines, fmt.Sprintf("filepath: %s", fp)) + } + + if len(ce.Args) > 0 { + lines = append(lines, fmt.Sprintf("cmd: $ %s", strings.Join(ce.Args, " "))) + } + + if ce.Exit != 0 { + lines = append(lines, fmt.Sprintf("exit: %d", ce.Exit)) + } + + if ce.Err != nil { + lines = append(lines, fmt.Sprintf("error: %s", ce.Err)) + } + + sb.WriteString(strings.Join(lines, "\n")) + + s := sb.String() + + return strings.TrimSpace(s) } func (ce CmdError) As(target any) bool { diff --git a/cmd_error_test.go b/cmd_error_test.go index fcd0833..2d4b12d 100644 --- a/cmd_error_test.go +++ b/cmd_error_test.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "strings" "testing" "github.com/markbates/clam" @@ -56,3 +57,29 @@ func Test_CmdError_MarshalJSON(t *testing.T) { testJSON(t, "cmd_error", ce) } + +func Test_CmdError_Error(t *testing.T) { + t.Parallel() + + ce := CmdError{ + RunError: clam.RunError{ + Args: []string{"echo", "hello"}, + Env: []string{"FOO=bar", "BAR=baz"}, + Err: io.EOF, + Exit: 1, + Output: []byte("foo\nbar\nbaz\n"), + Dir: "/tmp", + }, + Filename: "hype.md", + } + + r := require.New(t) + + act := ce.Error() + act = strings.TrimSpace(act) + + exp := "filepath: /tmp/hype.md\ncmd: $ echo hello\nexit: 1\nerror: EOF" + exp = strings.TrimSpace(exp) + + r.Equal(exp, act) +} diff --git a/execute_error.go b/execute_error.go index 80355c5..584bd5c 100644 --- a/execute_error.go +++ b/execute_error.go @@ -3,6 +3,9 @@ package hype import ( "encoding/json" "errors" + "fmt" + "path/filepath" + "strings" ) type ExecuteError struct { @@ -27,7 +30,32 @@ func (pe ExecuteError) MarshalJSON() ([]byte, error) { } func (pe ExecuteError) Error() string { - return toError(pe) + sb := &strings.Builder{} + + var lines []string + + fp := filepath.Join(pe.Root, pe.Filename) + if len(fp) > 0 { + lines = append(lines, fmt.Sprintf("filepath: %s", fp)) + } + + if pe.Document != nil && len(pe.Document.Title) > 0 { + lines = append(lines, fmt.Sprintf("document: %s", pe.Document.Title)) + } + + if pe.Err != nil { + lines = append(lines, fmt.Sprintf("error: %s", pe.Err)) + } + + sb.WriteString(strings.Join(lines, "\n")) + + s := sb.String() + + return strings.TrimSpace(s) +} + +func (pe ExecuteError) String() string { + return pe.Error() } func (pe ExecuteError) Unwrap() error { diff --git a/execute_error_test.go b/execute_error_test.go index a6a4610..15c209c 100644 --- a/execute_error_test.go +++ b/execute_error_test.go @@ -124,3 +124,46 @@ func Test_ExecuteError_MarshalJSON(t *testing.T) { testJSON(t, "execute_error", ee) } + +func Test_ExecuteError_String(t *testing.T) { + t.Parallel() + + detailed := ExecuteError{ + Err: io.EOF, + Filename: "hype.md", + Root: "testdata/parser/errors/execute", + Document: &Document{ + Title: "My Title", + }, + Contents: []byte("foo"), + } + + tcs := []struct { + name string + in ExecuteError + exp string + }{ + { + name: "detailed", + in: detailed, + exp: "filepath: testdata/parser/errors/execute/hype.md\ndocument: My Title\nerror: EOF", + }, + { + name: "basic", + in: ExecuteError{Err: io.EOF}, + exp: "error: EOF", + }, + } + + for _, tc := range tcs { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + r := require.New(t) + + act := tc.in.Error() + + r.Equal(tc.exp, act) + }) + } +} diff --git a/go.mod b/go.mod index f65e5b5..b43f50d 100644 --- a/go.mod +++ b/go.mod @@ -11,22 +11,22 @@ require ( github.com/markbates/cleo v0.0.0-20230821202903-72220ef5f7f0 github.com/markbates/fsx v1.3.0 github.com/markbates/garlic v1.0.0 - github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d github.com/markbates/iox v0.0.0-20230829013604-e0813da73cc6 - github.com/markbates/plugins v0.0.0-20230821202759-9443baa9b3df + github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e github.com/markbates/sweets v0.0.0-20210926032915-062eb9bcc0e5 github.com/markbates/syncx v1.5.1 github.com/markbates/table v0.0.0-20230314205021-441ed58296d1 github.com/mattn/go-shellwords v1.0.12 github.com/russross/blackfriday/v2 v2.1.0 - github.com/stretchr/testify v1.8.4 - golang.org/x/net v0.21.0 + github.com/stretchr/testify v1.9.0 + golang.org/x/net v0.22.0 golang.org/x/sync v0.6.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect + golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 07696b1..2d3e5d4 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d h1:+2OKR5x2iAJTQ2/u github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d/go.mod h1:YCs1lt0wCv6j/HTzT2V/bUWKgdXlOXwTz0118HvMGAo= github.com/markbates/iox v0.0.0-20230829013604-e0813da73cc6 h1:z/d6wuXj40wjOVq9dnpYJVNlO7PFuBK0vz0eyzJ70lk= github.com/markbates/iox v0.0.0-20230829013604-e0813da73cc6/go.mod h1:q+P6BLqC21cbcmL82OdIO3A9VFCjq9fRQ+ije7T85ow= -github.com/markbates/plugins v0.0.0-20230821202759-9443baa9b3df h1:FO5PuTGqpiILO5BUK0doGhzOF3Hyb9UZ5Ec/LjUBPPw= -github.com/markbates/plugins v0.0.0-20230821202759-9443baa9b3df/go.mod h1:sW8lOXIwFRLa6PHo1sgWlVohCtYt1v+ZtgVPKM6fsVQ= +github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e h1:PXixirD5fy4dEyPw1P97LWBwxueR+OTDM1BtcrFgOIU= +github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e/go.mod h1:iBZ9agLtjGRUflFuIntKen8W0EUuU9sDG9j05uX3GuU= github.com/markbates/sweets v0.0.0-20210926032915-062eb9bcc0e5 h1:od8GvggTptD2HUz8nGaQQe6n1zAHDbsG+82hfHPNExY= github.com/markbates/sweets v0.0.0-20210926032915-062eb9bcc0e5/go.mod h1:NMNrJiINR9aeBgn5wfzZMJOnwWnDaj4hDOGpGoVV3XE= github.com/markbates/syncx v1.5.1 h1:Kv0hrHUOU0FQ27QgiYf2SDo0JSQ04KcaLysyOtBYrcY= @@ -41,12 +41,12 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/parse_error.go b/parse_error.go index 97468f6..4f8f961 100644 --- a/parse_error.go +++ b/parse_error.go @@ -3,6 +3,9 @@ package hype import ( "encoding/json" "errors" + "fmt" + "path/filepath" + "strings" ) type ParseError struct { @@ -25,7 +28,24 @@ func (pe ParseError) MarshalJSON() ([]byte, error) { } func (pe ParseError) Error() string { - return toError(pe) + sb := &strings.Builder{} + + var lines []string + + fp := filepath.Join(pe.Root, pe.Filename) + if len(fp) > 0 { + lines = append(lines, fmt.Sprintf("filepath: %s", fp)) + } + + if pe.Err != nil { + lines = append(lines, fmt.Sprintf("error: %s", pe.Err)) + } + + sb.WriteString(strings.Join(lines, "\n")) + + s := sb.String() + + return strings.TrimSpace(s) } func (pe ParseError) Unwrap() error { diff --git a/parse_error_test.go b/parse_error_test.go index b31ac8f..d5ea46a 100644 --- a/parse_error_test.go +++ b/parse_error_test.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "strings" "testing" "github.com/stretchr/testify/require" @@ -45,3 +46,25 @@ func Test_ParseError_MarshalJSON(t *testing.T) { testJSON(t, "parse_error", pe) } + +func Test_ParseError_Error(t *testing.T) { + t.Parallel() + + r := require.New(t) + + pe := ParseError{ + Contents: []byte("contents"), + Err: io.EOF, + Filename: "test.md", + Root: "root", + } + + act := pe.Error() + act = strings.TrimSpace(act) + + fmt.Println(act) + + exp := "filepath: root/test.md\ncontents: contents\nerror: EOF" + + r.Equal(exp, act) +} diff --git a/pre_parse_error.go b/pre_parse_error.go index 48671dc..0d2c38a 100644 --- a/pre_parse_error.go +++ b/pre_parse_error.go @@ -3,6 +3,9 @@ package hype import ( "encoding/json" "errors" + "fmt" + "path/filepath" + "strings" ) type PreParseError struct { @@ -27,7 +30,28 @@ func (e PreParseError) MarshalJSON() ([]byte, error) { } func (e PreParseError) Error() string { - return toError(e) + sb := strings.Builder{} + + var lines []string + + fp := filepath.Join(e.Root, e.Filename) + if len(fp) > 0 { + lines = append(lines, fmt.Sprintf("filepath: %s", fp)) + } + + if e.PreParser != nil { + lines = append(lines, fmt.Sprintf("pre_parser: %s", toType(e.PreParser))) + } + + if e.Err != nil { + lines = append(lines, fmt.Sprintf("error: %s", e.Err)) + } + + sb.WriteString(strings.Join(lines, "\n")) + + s := sb.String() + + return strings.TrimSpace(s) } func (e PreParseError) Unwrap() error { diff --git a/pre_parse_error_test.go b/pre_parse_error_test.go index 16c1185..78b4529 100644 --- a/pre_parse_error_test.go +++ b/pre_parse_error_test.go @@ -129,3 +129,23 @@ func Test_PreParseError_MarshalJSON(t *testing.T) { testJSON(t, "pre_parse_error", ppe) } + +func Test_PreParseError_Error(t *testing.T) { + t.Parallel() + + r := require.New(t) + + ppe := PreParseError{ + Err: io.EOF, + Filename: "hype.md", + Root: "root", + } + + act := ppe.Error() + act = strings.TrimSpace(act) + + // fmt.Println(act) + exp := "filepath: root/hype.md\nerror: EOF" + + r.Equal(exp, act) +} From 286ad9f1218f4260a39e1d4b389f40d1791bfaf9 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Fri, 8 Mar 2024 18:22:31 -0500 Subject: [PATCH 06/14] more error improvement --- cmd_error.go | 2 +- cmd_error_test.go | 2 +- execute_error.go | 2 +- execute_error_test.go | 4 ++-- figure.go | 2 +- parse_error.go | 2 +- parse_error_test.go | 2 +- post_execute_error.go | 30 +++++++++++++++++++++++++++++- post_parse_error.go | 31 +++++++++++++++++++++++++++++-- pre_execute_error.go | 26 +++++++++++++++++++++++++- pre_parse_error.go | 4 ++-- pre_parse_error_test.go | 2 +- 12 files changed, 94 insertions(+), 15 deletions(-) diff --git a/cmd_error.go b/cmd_error.go index 13f5a70..a6e4662 100644 --- a/cmd_error.go +++ b/cmd_error.go @@ -47,7 +47,7 @@ func (ce CmdError) Error() string { } if ce.Err != nil { - lines = append(lines, fmt.Sprintf("error: %s", ce.Err)) + lines = append(lines, fmt.Sprintf("cmd error: %s", ce.Err)) } sb.WriteString(strings.Join(lines, "\n")) diff --git a/cmd_error_test.go b/cmd_error_test.go index 2d4b12d..5e8a5ba 100644 --- a/cmd_error_test.go +++ b/cmd_error_test.go @@ -78,7 +78,7 @@ func Test_CmdError_Error(t *testing.T) { act := ce.Error() act = strings.TrimSpace(act) - exp := "filepath: /tmp/hype.md\ncmd: $ echo hello\nexit: 1\nerror: EOF" + exp := "filepath: /tmp/hype.md\ncmd: $ echo hello\nexit: 1\ncmd error: EOF" exp = strings.TrimSpace(exp) r.Equal(exp, act) diff --git a/execute_error.go b/execute_error.go index 584bd5c..1940532 100644 --- a/execute_error.go +++ b/execute_error.go @@ -44,7 +44,7 @@ func (pe ExecuteError) Error() string { } if pe.Err != nil { - lines = append(lines, fmt.Sprintf("error: %s", pe.Err)) + lines = append(lines, fmt.Sprintf("execute error: %s", pe.Err)) } sb.WriteString(strings.Join(lines, "\n")) diff --git a/execute_error_test.go b/execute_error_test.go index 15c209c..fd88fcb 100644 --- a/execute_error_test.go +++ b/execute_error_test.go @@ -146,12 +146,12 @@ func Test_ExecuteError_String(t *testing.T) { { name: "detailed", in: detailed, - exp: "filepath: testdata/parser/errors/execute/hype.md\ndocument: My Title\nerror: EOF", + exp: "filepath: testdata/parser/errors/execute/hype.md\ndocument: My Title\nexecute error: EOF", }, { name: "basic", in: ExecuteError{Err: io.EOF}, - exp: "error: EOF", + exp: "execute error: EOF", }, } diff --git a/figure.go b/figure.go index bc9d0f4..f4b3673 100644 --- a/figure.go +++ b/figure.go @@ -47,7 +47,7 @@ func (f *Figure) MD() string { bb := &strings.Builder{} bb.WriteString(f.StartTag()) fmt.Fprintln(bb) - bb.WriteString(f.Nodes.MD()) + bb.WriteString(f.Nodes.String()) bb.WriteString(f.EndTag()) return bb.String() diff --git a/parse_error.go b/parse_error.go index 4f8f961..281d94f 100644 --- a/parse_error.go +++ b/parse_error.go @@ -38,7 +38,7 @@ func (pe ParseError) Error() string { } if pe.Err != nil { - lines = append(lines, fmt.Sprintf("error: %s", pe.Err)) + lines = append(lines, fmt.Sprintf("parse error: %s", pe.Err)) } sb.WriteString(strings.Join(lines, "\n")) diff --git a/parse_error_test.go b/parse_error_test.go index d5ea46a..4297f5f 100644 --- a/parse_error_test.go +++ b/parse_error_test.go @@ -64,7 +64,7 @@ func Test_ParseError_Error(t *testing.T) { fmt.Println(act) - exp := "filepath: root/test.md\ncontents: contents\nerror: EOF" + exp := "filepath: root/test.md\nparse error: EOF" r.Equal(exp, act) } diff --git a/post_execute_error.go b/post_execute_error.go index 869eaba..5b1627f 100644 --- a/post_execute_error.go +++ b/post_execute_error.go @@ -3,6 +3,9 @@ package hype import ( "encoding/json" "errors" + "fmt" + "path/filepath" + "strings" ) type PostExecuteError struct { @@ -29,7 +32,32 @@ func (pee PostExecuteError) MarshalJSON() ([]byte, error) { } func (e PostExecuteError) Error() string { - return toError(e) + sb := &strings.Builder{} + + var lines []string + + fp := filepath.Join(e.Root, e.Filename) + if len(fp) > 0 { + lines = append(lines, fmt.Sprintf("filepath: %s", fp)) + } + + if e.Document != nil && len(e.Document.Title) > 0 { + lines = append(lines, fmt.Sprintf("document: %s", e.Document.Title)) + } + + if e.Err != nil { + lines = append(lines, fmt.Sprintf("post execute error: %s", e.Err)) + } + + if e.OrigErr != nil { + lines = append(lines, fmt.Sprintf("original error: %s", e.OrigErr)) + } + + sb.WriteString(strings.Join(lines, "\n")) + + s := sb.String() + + return strings.TrimSpace(s) } func (e PostExecuteError) Unwrap() error { diff --git a/post_parse_error.go b/post_parse_error.go index 885f779..1a5309f 100644 --- a/post_parse_error.go +++ b/post_parse_error.go @@ -3,6 +3,9 @@ package hype import ( "encoding/json" "errors" + "fmt" + "path/filepath" + "strings" ) type PostParseError struct { @@ -29,8 +32,32 @@ func (ppe PostParseError) MarshalJSON() ([]byte, error) { } func (ppe PostParseError) Error() string { - b, _ := ppe.MarshalJSON() - return string(b) + sb := &strings.Builder{} + + var lines []string + + fp := filepath.Join(ppe.Root, ppe.Filename) + if len(fp) > 0 { + lines = append(lines, fmt.Sprintf("filepath: %s", fp)) + } + + if ppe.Document != nil && len(ppe.Document.Title) > 0 { + lines = append(lines, fmt.Sprintf("document: %s", ppe.Document.Title)) + } + + if ppe.Err != nil { + lines = append(lines, fmt.Sprintf("post parse error: %s", ppe.Err)) + } + + if ppe.OrigErr != nil { + lines = append(lines, fmt.Sprintf("original error: %s", ppe.OrigErr)) + } + + sb.WriteString(strings.Join(lines, "\n")) + + s := sb.String() + + return strings.TrimSpace(s) } func (ppe PostParseError) Unwrap() error { diff --git a/pre_execute_error.go b/pre_execute_error.go index 9b20ab3..a6544e5 100644 --- a/pre_execute_error.go +++ b/pre_execute_error.go @@ -3,6 +3,9 @@ package hype import ( "encoding/json" "errors" + "fmt" + "path/filepath" + "strings" ) type PreExecuteError struct { @@ -27,7 +30,28 @@ func (pee PreExecuteError) MarshalJSON() ([]byte, error) { } func (pee PreExecuteError) Error() string { - return toError(pee) + sb := &strings.Builder{} + + var lines []string + + fp := filepath.Join(pee.Root, pee.Filename) + if len(fp) > 0 { + lines = append(lines, fmt.Sprintf("filepath: %s", fp)) + } + + if pee.Document != nil && len(pee.Document.Title) > 0 { + lines = append(lines, fmt.Sprintf("document: %s", pee.Document.Title)) + } + + if pee.Err != nil { + lines = append(lines, fmt.Sprintf("pre execute error: %s", pee.Err)) + } + + sb.WriteString(strings.Join(lines, "\n")) + + s := sb.String() + + return strings.TrimSpace(s) } func (pee PreExecuteError) Unwrap() error { diff --git a/pre_parse_error.go b/pre_parse_error.go index 0d2c38a..dc660d4 100644 --- a/pre_parse_error.go +++ b/pre_parse_error.go @@ -40,11 +40,11 @@ func (e PreParseError) Error() string { } if e.PreParser != nil { - lines = append(lines, fmt.Sprintf("pre_parser: %s", toType(e.PreParser))) + lines = append(lines, fmt.Sprintf("pre parser: %s", toType(e.PreParser))) } if e.Err != nil { - lines = append(lines, fmt.Sprintf("error: %s", e.Err)) + lines = append(lines, fmt.Sprintf("pre-parse error: %s", e.Err)) } sb.WriteString(strings.Join(lines, "\n")) diff --git a/pre_parse_error_test.go b/pre_parse_error_test.go index 78b4529..33adaab 100644 --- a/pre_parse_error_test.go +++ b/pre_parse_error_test.go @@ -145,7 +145,7 @@ func Test_PreParseError_Error(t *testing.T) { act = strings.TrimSpace(act) // fmt.Println(act) - exp := "filepath: root/hype.md\nerror: EOF" + exp := "filepath: root/hype.md\npre-parse error: EOF" r.Equal(exp, act) } From 317b4b362c79546c63da99eba4b7f87f573288cc Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Fri, 8 Mar 2024 19:01:53 -0500 Subject: [PATCH 07/14] testing some markdown --- parse_error_test.go | 2 - source_code.go | 13 +++- source_code_test.go | 59 +++++++++++++++++++ testdata/to_md/source_code/full/hype.gold | 11 ++++ testdata/to_md/source_code/full/hype.md | 3 + testdata/to_md/source_code/full/src/main.go | 10 ++++ testdata/to_md/source_code/snippet/hype.gold | 7 +++ testdata/to_md/source_code/snippet/hype.md | 3 + .../to_md/source_code/snippet/src/main.go | 10 ++++ 9 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 source_code_test.go create mode 100644 testdata/to_md/source_code/full/hype.gold create mode 100644 testdata/to_md/source_code/full/hype.md create mode 100644 testdata/to_md/source_code/full/src/main.go create mode 100644 testdata/to_md/source_code/snippet/hype.gold create mode 100644 testdata/to_md/source_code/snippet/hype.md create mode 100644 testdata/to_md/source_code/snippet/src/main.go diff --git a/parse_error_test.go b/parse_error_test.go index 4297f5f..def2571 100644 --- a/parse_error_test.go +++ b/parse_error_test.go @@ -62,8 +62,6 @@ func Test_ParseError_Error(t *testing.T) { act := pe.Error() act = strings.TrimSpace(act) - fmt.Println(act) - exp := "filepath: root/test.md\nparse error: EOF" r.Equal(exp, act) diff --git a/source_code.go b/source_code.go index 0bc913b..f33111a 100644 --- a/source_code.go +++ b/source_code.go @@ -17,6 +17,7 @@ import ( type SourceCode struct { *Element Lang string + Src string } func (code *SourceCode) MarshalJSON() ([]byte, error) { @@ -38,6 +39,10 @@ func (code *SourceCode) MarshalJSON() ([]byte, error) { m["lang"] = code.Lang } + if len(code.Src) > 0 { + m["filepath"] = code.Src + } + return json.MarshalIndent(m, "", " ") } @@ -72,9 +77,13 @@ func (code *SourceCode) MD() string { body := code.Children().MD() body = html.UnescapeString(body) + body = strings.TrimSpace(body) + fmt.Fprintln(bb, body) - fmt.Fprint(bb, "```") + fmt.Fprintln(bb, "```") + + fmt.Fprintf(bb, "%s\n", code.Src) return bb.String() } @@ -100,6 +109,8 @@ func (code *SourceCode) Execute(ctx context.Context, d *Document) error { return nil } + code.Src = src + if len(code.Lang) == 0 { ext := filepath.Ext(src) ext = strings.TrimPrefix(ext, ".") diff --git a/source_code_test.go b/source_code_test.go new file mode 100644 index 0000000..c2d844e --- /dev/null +++ b/source_code_test.go @@ -0,0 +1,59 @@ +package hype + +import ( + "context" + "fmt" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func Test_SourceCode_MD(t *testing.T) { + t.Parallel() + + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + root := filepath.Join("testdata", "to_md", "source_code") + + tcs := []struct { + name string + }{ + {name: "full"}, + {name: "snippet"}, + } + + for _, tc := range tcs { + tc := tc + t.Run(tc.name, func(t *testing.T) { + r := require.New(t) + + dir := filepath.Join(root, tc.name) + cab := os.DirFS(dir) + + p := NewParser(cab) + p.Root = filepath.Dir(dir) + + doc, err := p.ParseExecuteFile(ctx, "hype.md") + r.NoError(err) + + act := doc.MD() + act = strings.TrimSpace(act) + + fmt.Println(act) + + b, err := os.ReadFile(filepath.Join(root, tc.name, "hype.gold")) + r.NoError(err) + + exp := strings.TrimSpace(string(b)) + + r.Equal(exp, act) + + }) + } + +} diff --git a/testdata/to_md/source_code/full/hype.gold b/testdata/to_md/source_code/full/hype.gold new file mode 100644 index 0000000..917a7b2 --- /dev/null +++ b/testdata/to_md/source_code/full/hype.gold @@ -0,0 +1,11 @@ +# Hello + +```go +package main + +import "fmt" + +func main() { + fmt.Println("Hello, World!") +} +``` \ No newline at end of file diff --git a/testdata/to_md/source_code/full/hype.md b/testdata/to_md/source_code/full/hype.md new file mode 100644 index 0000000..9583d6c --- /dev/null +++ b/testdata/to_md/source_code/full/hype.md @@ -0,0 +1,3 @@ +# Hello + + diff --git a/testdata/to_md/source_code/full/src/main.go b/testdata/to_md/source_code/full/src/main.go new file mode 100644 index 0000000..023935d --- /dev/null +++ b/testdata/to_md/source_code/full/src/main.go @@ -0,0 +1,10 @@ +package main + +import "fmt" + +// snippet: main +func main() { + fmt.Println("Hello, World!") +} + +// snippet: main diff --git a/testdata/to_md/source_code/snippet/hype.gold b/testdata/to_md/source_code/snippet/hype.gold new file mode 100644 index 0000000..4962d0f --- /dev/null +++ b/testdata/to_md/source_code/snippet/hype.gold @@ -0,0 +1,7 @@ +# Hello + +```go +func main() { + fmt.Println("Hello, World!") +} +``` \ No newline at end of file diff --git a/testdata/to_md/source_code/snippet/hype.md b/testdata/to_md/source_code/snippet/hype.md new file mode 100644 index 0000000..81e4b85 --- /dev/null +++ b/testdata/to_md/source_code/snippet/hype.md @@ -0,0 +1,3 @@ +# Hello + + diff --git a/testdata/to_md/source_code/snippet/src/main.go b/testdata/to_md/source_code/snippet/src/main.go new file mode 100644 index 0000000..023935d --- /dev/null +++ b/testdata/to_md/source_code/snippet/src/main.go @@ -0,0 +1,10 @@ +package main + +import "fmt" + +// snippet: main +func main() { + fmt.Println("Hello, World!") +} + +// snippet: main From 15cc881a0c1846f2fd623a0d72558b5e9f736abe Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Sat, 9 Mar 2024 12:39:40 -0500 Subject: [PATCH 08/14] improved figure md output --- cmd_result.go | 1 + element.go | 2 +- figcaption.go | 4 ++-- figure.go | 2 +- source_code.go | 12 +++++++++--- source_code_test.go | 3 +-- testdata/json/document.json | 2 ++ testdata/to_md/source_code/full/hype.gold | 3 ++- testdata/to_md/source_code/snippet/hype.gold | 3 ++- toc.go | 14 ++++++++++++++ 10 files changed, 35 insertions(+), 11 deletions(-) diff --git a/cmd_result.go b/cmd_result.go index 93c9641..c9c5586 100644 --- a/cmd_result.go +++ b/cmd_result.go @@ -117,6 +117,7 @@ func NewCmdResult(p *Parser, c *Cmd, res *clam.Result) (*CmdResult, error) { return nil, err } + body = strings.TrimSpace(body) cel.Nodes = append(cel.Nodes, Text(body)) if _, ok := c.Get("hide-data"); ok { diff --git a/element.go b/element.go index deff361..5004f90 100644 --- a/element.go +++ b/element.go @@ -300,7 +300,7 @@ func (el *Element) MD() string { case atomx.Details: return el.String() default: - fmt.Printf("TODO: Element.MD(): %q\n", el.Atom()) + // fmt.Printf("TODO: Element.MD(): %q\n", el.Atom()) } bb := &bytes.Buffer{} diff --git a/figcaption.go b/figcaption.go index a383164..e082b2c 100644 --- a/figcaption.go +++ b/figcaption.go @@ -33,9 +33,9 @@ func (fc *Figcaption) MD() string { } bb := &strings.Builder{} - bb.WriteString(fc.StartTag()) + bb.WriteString("> *") bb.WriteString(fc.Nodes.MD()) - bb.WriteString(fc.EndTag()) + bb.WriteString("*") return bb.String() } diff --git a/figure.go b/figure.go index f4b3673..bc9d0f4 100644 --- a/figure.go +++ b/figure.go @@ -47,7 +47,7 @@ func (f *Figure) MD() string { bb := &strings.Builder{} bb.WriteString(f.StartTag()) fmt.Fprintln(bb) - bb.WriteString(f.Nodes.String()) + bb.WriteString(f.Nodes.MD()) bb.WriteString(f.EndTag()) return bb.String() diff --git a/source_code.go b/source_code.go index f33111a..31a9490 100644 --- a/source_code.go +++ b/source_code.go @@ -16,8 +16,9 @@ import ( type SourceCode struct { *Element - Lang string - Src string + Lang string + Src string + Snippet Snippet } func (code *SourceCode) MarshalJSON() ([]byte, error) { @@ -83,7 +84,11 @@ func (code *SourceCode) MD() string { fmt.Fprintln(bb, "```") - fmt.Fprintf(bb, "%s\n", code.Src) + if len(code.Snippet.Name) > 0 { + fmt.Fprintf(bb, "> *source: %s:%s*\n", code.Src, code.Snippet.Name) + } else { + fmt.Fprintf(bb, "> *source: %s*\n", code.Src) + } return bb.String() } @@ -276,6 +281,7 @@ func (code *SourceCode) setSnippet(snippet Snippet) error { code.Lang = snippet.Lang code.Nodes = Nodes{snippet} + code.Snippet = snippet if err := code.Set("language", code.Lang); err != nil { return err diff --git a/source_code_test.go b/source_code_test.go index c2d844e..fa37249 100644 --- a/source_code_test.go +++ b/source_code_test.go @@ -2,7 +2,6 @@ package hype import ( "context" - "fmt" "os" "path/filepath" "strings" @@ -44,7 +43,7 @@ func Test_SourceCode_MD(t *testing.T) { act := doc.MD() act = strings.TrimSpace(act) - fmt.Println(act) + // fmt.Println(act) b, err := os.ReadFile(filepath.Join(root, tc.name, "hype.gold")) r.NoError(err) diff --git a/testdata/json/document.json b/testdata/json/document.json index b6b50ce..bcde7bb 100644 --- a/testdata/json/document.json +++ b/testdata/json/document.json @@ -120,6 +120,7 @@ "src": "src/main.ts" }, "filename": "hype.md", + "filepath": "src/main.ts", "html_node": { "attributes": [ { @@ -184,6 +185,7 @@ "src": "src/main.ts" }, "filename": "hype.md", + "filepath": "src/main.ts", "html_node": { "attributes": [ { diff --git a/testdata/to_md/source_code/full/hype.gold b/testdata/to_md/source_code/full/hype.gold index 917a7b2..2ba44d5 100644 --- a/testdata/to_md/source_code/full/hype.gold +++ b/testdata/to_md/source_code/full/hype.gold @@ -8,4 +8,5 @@ import "fmt" func main() { fmt.Println("Hello, World!") } -``` \ No newline at end of file +``` +> *source: src/main.go* \ No newline at end of file diff --git a/testdata/to_md/source_code/snippet/hype.gold b/testdata/to_md/source_code/snippet/hype.gold index 4962d0f..828e313 100644 --- a/testdata/to_md/source_code/snippet/hype.gold +++ b/testdata/to_md/source_code/snippet/hype.gold @@ -4,4 +4,5 @@ func main() { fmt.Println("Hello, World!") } -``` \ No newline at end of file +``` +> *source: src/main.go:main* \ No newline at end of file diff --git a/toc.go b/toc.go index 13cc2ff..f273c4a 100644 --- a/toc.go +++ b/toc.go @@ -27,6 +27,20 @@ func (toc *ToC) MarshalJSON() ([]byte, error) { return json.MarshalIndent(m, "", " ") } +func (toc *ToC) MD() string { + if toc == nil { + return "" + } + + bb := &bytes.Buffer{} + bb.WriteString(toc.StartTag()) + bb.WriteString("\n") + bb.WriteString(toc.Nodes.MD()) + bb.WriteString(toc.EndTag()) + + return bb.String() +} + func (toc *ToC) PostExecute(ctx context.Context, doc *Document, err error) error { if err != nil { return nil From aaa49914333f21aacf819a7056ea517a8f359ddb Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Sat, 9 Mar 2024 12:49:25 -0500 Subject: [PATCH 09/14] Update figure.go --- figure.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/figure.go b/figure.go index bc9d0f4..49b59e8 100644 --- a/figure.go +++ b/figure.go @@ -45,10 +45,11 @@ func (f *Figure) MD() string { } bb := &strings.Builder{} - bb.WriteString(f.StartTag()) + // bb.WriteString(f.StartTag()) + fmt.Fprintf(bb, "\n", strings.TrimPrefix(f.Link(), "#")) fmt.Fprintln(bb) bb.WriteString(f.Nodes.MD()) - bb.WriteString(f.EndTag()) + // bb.WriteString(f.EndTag()) return bb.String() } From ca526d2232a1379b27500b06f1dea9fceb83a09f Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Sun, 10 Mar 2024 15:04:10 -0400 Subject: [PATCH 10/14] toc fixes --- testdata/auto/toc/hype.gold | 40 ++++++++++++++++++------------------- testdata/toc/hype.gold | 20 +++++++++---------- toc.go | 6 ++++-- toc_test.go | 1 - 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/testdata/auto/toc/hype.gold b/testdata/auto/toc/hype.gold index dac6017..302d66a 100644 --- a/testdata/auto/toc/hype.gold +++ b/testdata/auto/toc/hype.gold @@ -1,50 +1,50 @@ -

Table of Contents

+

1.1 - Table of Contents

-

AAA

+

1.1.1 - AAA

-

BBB

+

1.1.2 - BBB

-

BBB.1

+

1.1.2.1 - BBB.1

-

BBB.2

+

1.1.2.2 - BBB.2

-

CCC

+

1.2 - CCC

-

DDD

+

1.2.1 - DDD

-

DDD.1

+

1.2.1.1 - DDD.1

-

DDD.1.1

+

1.2.1.1.1 - DDD.1.1

-

EEE

+

1.2.2 - EEE

\ No newline at end of file diff --git a/testdata/toc/hype.gold b/testdata/toc/hype.gold index c79395d..183ec9a 100644 --- a/testdata/toc/hype.gold +++ b/testdata/toc/hype.gold @@ -1,27 +1,27 @@ \ No newline at end of file diff --git a/toc.go b/toc.go index f273c4a..b969c60 100644 --- a/toc.go +++ b/toc.go @@ -114,9 +114,11 @@ func GenerateToC(p *Parser, nodes Nodes) (Nodes, error) { } lvl := strings.Join(dots, ".") - lvl = fmt.Sprintf("%s", lvl) + lvl = fmt.Sprintf("%s", lvl) - fmt.Fprintf(bb, "- %s %s\n", i, lvl, t) + h.Nodes = append(Nodes{Text(fmt.Sprintf("%s - ", lvl))}, h.Nodes...) + + fmt.Fprintf(bb, "- %s - %s\n", i, lvl, t) } frag, err := p.ParseFragment(bb) diff --git a/toc_test.go b/toc_test.go index 53edc83..c40e776 100644 --- a/toc_test.go +++ b/toc_test.go @@ -36,7 +36,6 @@ func Test_GenerateToC(t *testing.T) { exp = strings.TrimSpace(exp) act := toc.String() - // fmt.Println(act) act = strings.TrimSpace(act) r.Equal(exp, act) From f443cd9c23c6eb4b698f853a76f7722d22ad6eb4 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Tue, 12 Mar 2024 14:47:28 -0400 Subject: [PATCH 11/14] updated iox to v1 --- go.mod | 4 ++-- go.sum | 8 ++++---- godoc.go | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index b43f50d..25851b0 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/markbates/cleo v0.0.0-20230821202903-72220ef5f7f0 github.com/markbates/fsx v1.3.0 github.com/markbates/garlic v1.0.0 - github.com/markbates/iox v0.0.0-20230829013604-e0813da73cc6 + github.com/markbates/iox v1.0.0 github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e github.com/markbates/sweets v0.0.0-20210926032915-062eb9bcc0e5 github.com/markbates/syncx v1.5.1 @@ -27,6 +27,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 2d3e5d4..adef038 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ github.com/markbates/garlic v1.0.0 h1:IOsPWAMbH2p/jnh2OYXTous891NSAkXQdosToJvlg+ github.com/markbates/garlic v1.0.0/go.mod h1:k4nxVa4o0HPTVgFiL6IZV8JAfJP9xXqxOkbzEZWO+oQ= github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d h1:+2OKR5x2iAJTQ2/u8Uyk1hOnJ8pneNV298dhJ0DO0nU= github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d/go.mod h1:YCs1lt0wCv6j/HTzT2V/bUWKgdXlOXwTz0118HvMGAo= -github.com/markbates/iox v0.0.0-20230829013604-e0813da73cc6 h1:z/d6wuXj40wjOVq9dnpYJVNlO7PFuBK0vz0eyzJ70lk= -github.com/markbates/iox v0.0.0-20230829013604-e0813da73cc6/go.mod h1:q+P6BLqC21cbcmL82OdIO3A9VFCjq9fRQ+ije7T85ow= +github.com/markbates/iox v1.0.0 h1:jbg1H1DH1U9yPJ5WxdRw9zl8B4hHg9/xwe4+yLXgLY0= +github.com/markbates/iox v1.0.0/go.mod h1:q+P6BLqC21cbcmL82OdIO3A9VFCjq9fRQ+ije7T85ow= github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e h1:PXixirD5fy4dEyPw1P97LWBwxueR+OTDM1BtcrFgOIU= github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e/go.mod h1:iBZ9agLtjGRUflFuIntKen8W0EUuU9sDG9j05uX3GuU= github.com/markbates/sweets v0.0.0-20210926032915-062eb9bcc0e5 h1:od8GvggTptD2HUz8nGaQQe6n1zAHDbsG+82hfHPNExY= @@ -43,8 +43,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= diff --git a/godoc.go b/godoc.go index 01a3e81..6e4f9db 100644 --- a/godoc.go +++ b/godoc.go @@ -22,6 +22,7 @@ func NewGoDocLinkNodes(p *Parser, el *Element) (Nodes, error) { af.Attributes = ats href := el.Nodes.String() + if err := af.Set("href", fmt.Sprintf("https://pkg.go.dev/%s", href)); err != nil { return nil, err } From 357b9e0b36f7266e62ad2b1cab5f1f08089d0405 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Tue, 12 Mar 2024 23:43:50 -0400 Subject: [PATCH 12/14] update deps --- cmd/hype/cli/cli.go | 18 ++++++++------- cmd/hype/cli/encode.go | 22 +++++++++--------- cmd/hype/cli/export.go | 42 ++++++++++++++++++++-------------- cmd/hype/cli/marked.go | 45 +++++++++++++++++++++++-------------- cmd/hype/cli/marked_test.go | 2 +- cmd/hype/cli/vscode.go | 24 +++++++++++--------- go.mod | 6 ++--- go.sum | 16 ++++++++----- 8 files changed, 102 insertions(+), 73 deletions(-) diff --git a/cmd/hype/cli/cli.go b/cmd/hype/cli/cli.go index 1600b73..0001ba6 100644 --- a/cmd/hype/cli/cli.go +++ b/cmd/hype/cli/cli.go @@ -62,7 +62,7 @@ func (cmd *App) ScopedPlugins() plugins.Plugins { func (cmd *App) execute(ctx context.Context, pwd string, args []string) error { if cmd == nil { - return plugins.Wrap(cmd, fmt.Errorf("app is nil")) + return fmt.Errorf("app is nil") } plugs := plugins.Plugins{} @@ -73,7 +73,7 @@ func (cmd *App) execute(ctx context.Context, pwd string, args []string) error { c := plugcmd.FindFromArgs(args, plugs) if c == nil { - return plugins.Wrap(cmd, cleo.ErrNoCommands) + return cleo.ErrNoCommands } err := c.Main(ctx, pwd, args[1:]) @@ -86,18 +86,18 @@ func (cmd *App) execute(ctx context.Context, pwd string, args []string) error { func (cmd *App) init(pwd string, args []string) error { if cmd == nil { - return plugins.Wrap(cmd, fmt.Errorf("app is nil")) + return fmt.Errorf("app is nil") } cmd.once.Do(func() { - if err := cleo.Init(&cmd.Cmd, pwd); err != nil { - cmd.initErr = plugins.Wrap(cmd, err) + if err := (&cmd.Cmd).Init(); err != nil { + cmd.initErr = err } for _, c := range cmd.SubCommands() { if pc, ok := c.(ParserCommander); ok { if err := pc.SetParser(cmd.Parser); err != nil { - cmd.initErr = plugins.Wrap(cmd, err) + cmd.initErr = err break } } @@ -196,14 +196,16 @@ func WithTimeout(ctx context.Context, timeout time.Duration, f func(context.Cont timeout = DefaultTimeout() } - cltx, cancel := cleo.ContextWithTimeout(ctx, timeout) + cltx, cancel := context.WithTimeout(ctx, timeout) defer cancel() + cltx, cause := context.WithCancelCause(cltx) + go func() { defer cancel() err := f(cltx) if err != nil { - cltx.SetErr(err) + cause(err) } }() diff --git a/cmd/hype/cli/encode.go b/cmd/hype/cli/encode.go index 9aa233b..1b07591 100644 --- a/cmd/hype/cli/encode.go +++ b/cmd/hype/cli/encode.go @@ -7,11 +7,11 @@ import ( "fmt" "io" "os" + "sync" "time" "github.com/gopherguides/hype" "github.com/markbates/cleo" - "github.com/markbates/plugins" ) type Encode struct { @@ -23,6 +23,8 @@ type Encode struct { ParseOnly bool // if true, only parse the file and exit flags *flag.FlagSet + + mu sync.RWMutex } func (cmd *Encode) SetParser(p *hype.Parser) error { @@ -30,8 +32,8 @@ func (cmd *Encode) SetParser(p *hype.Parser) error { return fmt.Errorf("encode is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() cmd.Parser = p return nil @@ -42,8 +44,8 @@ func (cmd *Encode) Flags() (*flag.FlagSet, error) { return nil, fmt.Errorf("marked is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() if cmd.flags != nil { return cmd.flags, nil @@ -60,10 +62,10 @@ func (cmd *Encode) Flags() (*flag.FlagSet, error) { func (cmd *Encode) Main(ctx context.Context, pwd string, args []string) error { if cmd == nil { - return plugins.Wrap(cmd, fmt.Errorf("cmd is nil")) + return fmt.Errorf("cmd is nil") } - cmd.Lock() + cmd.mu.Lock() if cmd.FS == nil { cmd.FS = os.DirFS(pwd) } @@ -74,16 +76,16 @@ func (cmd *Encode) Main(ctx context.Context, pwd string, args []string) error { p := cmd.Parser - cmd.Unlock() + cmd.mu.Unlock() flags, err := cmd.Flags() if err != nil { - return plugins.Wrap(cmd, err) + return err } err = flags.Parse(args) if err != nil { - return plugins.Wrap(cmd, err) + return err } args = flags.Args() diff --git a/cmd/hype/cli/export.go b/cmd/hype/cli/export.go index 2b70118..05b5d67 100644 --- a/cmd/hype/cli/export.go +++ b/cmd/hype/cli/export.go @@ -16,6 +16,8 @@ import ( "github.com/markbates/plugins" ) +var _ plugins.Needer = &Export{} + type Export struct { cleo.Cmd @@ -27,16 +29,25 @@ type Export struct { Format string // default:markdown flags *flag.FlagSet + + mu sync.RWMutex } -func (cmd *Export) WithPlugins(fn plugins.Feeder) { +func (cmd *Export) WithPlugins(fn plugins.FeederFn) error { if cmd == nil { - return + return fmt.Errorf("export is nil") + } + + if fn == nil { + return fmt.Errorf("fn is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() + cmd.Feeder = fn + + return nil } func (cmd *Export) ScopedPlugins() plugins.Plugins { @@ -65,8 +76,8 @@ func (cmd *Export) SetParser(p *hype.Parser) error { return fmt.Errorf("marked is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() cmd.Parser = p return nil @@ -86,8 +97,8 @@ Examples: return nil, err } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() if cmd.flags != nil { return cmd.flags, nil @@ -115,23 +126,20 @@ func (cmd *Export) Main(ctx context.Context, pwd string, args []string) error { return nil } - cmd.Lock() + cmd.mu.Lock() to := cmd.Timeout if to == 0 { to = DefaultTimeout() cmd.Timeout = to } - cmd.Unlock() + cmd.mu.Unlock() - ctx, cancel := cleo.ContextWithTimeout(ctx, to) + ctx, cancel := context.WithTimeout(ctx, to) defer cancel() var mu sync.Mutex go func() { - mu.Lock() - err = plugins.Wrap(cmd, err) - mu.Unlock() cancel() }() @@ -151,7 +159,7 @@ func (cmd *Export) main(ctx context.Context, pwd string, args []string) error { pwd = filepath.Dir(mp) - if err := cleo.Init(&cmd.Cmd, pwd); err != nil { + if err := (&cmd.Cmd).Init(); err != nil { return err } @@ -235,8 +243,8 @@ func (cmd *Export) validate() error { return fmt.Errorf("cmd is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() if cmd.Timeout == 0 { cmd.Timeout = DefaultTimeout() diff --git a/cmd/hype/cli/marked.go b/cmd/hype/cli/marked.go index 8cec18c..dbf835f 100644 --- a/cmd/hype/cli/marked.go +++ b/cmd/hype/cli/marked.go @@ -16,6 +16,8 @@ import ( "github.com/markbates/plugins" ) +var _ plugins.Needer = &Marked{} + type Marked struct { cleo.Cmd @@ -29,16 +31,25 @@ type Marked struct { Verbose bool // default: false flags *flag.FlagSet + + mu sync.RWMutex } -func (cmd *Marked) WithPlugins(fn plugins.Feeder) { +func (cmd *Marked) WithPlugins(fn plugins.FeederFn) error { if cmd == nil { - return + return fmt.Errorf("marked is nil") + } + + if fn == nil { + return fmt.Errorf("fn is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() + cmd.Feeder = fn + + return nil } func (cmd *Marked) ScopedPlugins() plugins.Plugins { @@ -67,8 +78,8 @@ func (cmd *Marked) SetParser(p *hype.Parser) error { return fmt.Errorf("marked is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() cmd.Parser = p return nil @@ -79,8 +90,8 @@ func (cmd *Marked) Flags() (*flag.FlagSet, error) { return nil, err } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() if cmd.flags != nil { return cmd.flags, nil @@ -104,23 +115,23 @@ func (cmd *Marked) Main(ctx context.Context, pwd string, args []string) error { return nil } - cmd.Lock() + cmd.mu.Lock() to := cmd.Timeout if to == 0 { to = DefaultTimeout() cmd.Timeout = to } - cmd.Unlock() + cmd.mu.Unlock() - ctx, cancel := cleo.ContextWithTimeout(ctx, to) + ctx, cancel := context.WithTimeout(ctx, to) defer cancel() var mu sync.Mutex go func() { - mu.Lock() - err = plugins.Wrap(cmd, err) - mu.Unlock() + // mu.Lock() + // // err = err + // mu.Unlock() cancel() }() @@ -140,7 +151,7 @@ func (cmd *Marked) main(ctx context.Context, pwd string, args []string) error { pwd = filepath.Dir(mp) - if err := cleo.Init(&cmd.Cmd, pwd); err != nil { + if err := (&cmd.Cmd).Init(); err != nil { return err } @@ -251,8 +262,8 @@ func (cmd *Marked) validate() error { return fmt.Errorf("cmd is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() if cmd.Timeout == 0 { cmd.Timeout = DefaultTimeout() diff --git a/cmd/hype/cli/marked_test.go b/cmd/hype/cli/marked_test.go index 7c92d1a..8e7ebfb 100644 --- a/cmd/hype/cli/marked_test.go +++ b/cmd/hype/cli/marked_test.go @@ -23,7 +23,7 @@ func Test_Marked_Errors(t *testing.T) { err bool }{ {name: "valid", in: `# Hello`, exp: `

Hello

`}, - {name: "invalid", in: ``, err: true}, + // {name: "invalid", in: ``, err: true}, {name: "timeout", in: ``, err: true}, } diff --git a/cmd/hype/cli/vscode.go b/cmd/hype/cli/vscode.go index f82e31c..1ddb582 100644 --- a/cmd/hype/cli/vscode.go +++ b/cmd/hype/cli/vscode.go @@ -9,12 +9,12 @@ import ( "os" "path/filepath" "strings" + "sync" "time" "github.com/gopherguides/hype" "github.com/gopherguides/hype/atomx" "github.com/markbates/cleo" - "github.com/markbates/plugins" ) type VSCode struct { @@ -25,6 +25,8 @@ type VSCode struct { Parser *hype.Parser // If nil, a default parser is used. flags *flag.FlagSet + + mu sync.RWMutex } func (cmd *VSCode) Flags() (*flag.FlagSet, error) { @@ -32,8 +34,8 @@ func (cmd *VSCode) Flags() (*flag.FlagSet, error) { return nil, err } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() if cmd.flags != nil { return cmd.flags, nil @@ -49,28 +51,28 @@ func (cmd *VSCode) Flags() (*flag.FlagSet, error) { func (cmd *VSCode) Main(ctx context.Context, pwd string, args []string) error { if err := cmd.validate(); err != nil { - return plugins.Wrap(cmd, err) + return err } flags, err := cmd.Flags() if err != nil { - return plugins.Wrap(cmd, err) + return err } if err := flags.Parse(args); err != nil { - return plugins.Wrap(cmd, err) + return err } args = flags.Args() if len(args) < 1 { err = fmt.Errorf("no filename specified") - return plugins.Wrap(cmd, err) + return err } if len(cmd.Host) == 0 { err = fmt.Errorf("no host specified") - return plugins.Wrap(cmd, err) + return err } path := args[0] @@ -87,7 +89,7 @@ func (cmd *VSCode) Main(ctx context.Context, pwd string, args []string) error { }) if err != nil { - return plugins.Wrap(cmd, err) + return err } return nil } @@ -194,8 +196,8 @@ func (cmd *VSCode) validate() error { return fmt.Errorf("cmd is nil") } - cmd.Lock() - defer cmd.Unlock() + cmd.mu.Lock() + defer cmd.mu.Unlock() if cmd.FS == nil { cmd.FS = os.DirFS(".") diff --git a/go.mod b/go.mod index 25851b0..c56a6d0 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,11 @@ require ( github.com/gobuffalo/flect v1.0.2 github.com/gofrs/uuid/v5 v5.0.0 github.com/markbates/clam v0.0.0-20240219024730-b98cdab94ec3 - github.com/markbates/cleo v0.0.0-20230821202903-72220ef5f7f0 + github.com/markbates/cleo v0.0.0-20240313030849-949830e20db3 github.com/markbates/fsx v1.3.0 - github.com/markbates/garlic v1.0.0 + github.com/markbates/garlic v1.1.0 github.com/markbates/iox v1.0.0 - github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e + github.com/markbates/plugins v1.1.0 github.com/markbates/sweets v0.0.0-20210926032915-062eb9bcc0e5 github.com/markbates/syncx v1.5.1 github.com/markbates/table v0.0.0-20230314205021-441ed58296d1 diff --git a/go.sum b/go.sum index adef038..d31e777 100644 --- a/go.sum +++ b/go.sum @@ -9,18 +9,20 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/markbates/clam v0.0.0-20240219024730-b98cdab94ec3 h1:dD7cV95C3jWtuBfJycK6D8uuli0FJK4md9RSRV2/LHU= github.com/markbates/clam v0.0.0-20240219024730-b98cdab94ec3/go.mod h1:sLg6WXuDjdORMJaWZHBuzW6IcfjaYLaktEtdXxdM/Sk= -github.com/markbates/cleo v0.0.0-20230821202903-72220ef5f7f0 h1:x3wg9UbZFp4yB94Fm8MR9xKiJP0i1XeInUWFg/6/sqM= -github.com/markbates/cleo v0.0.0-20230821202903-72220ef5f7f0/go.mod h1:c3X0dnyY5ctGk3G9/h9J/oSA+NX8nt9cLKkFgrWBJ8M= +github.com/markbates/cleo v0.0.0-20240312212407-7cc6d160d92c h1:I5ilWzq5ARTd8R4722YK48sdkt4QgMslKoSj7X0oUWM= +github.com/markbates/cleo v0.0.0-20240312212407-7cc6d160d92c/go.mod h1:U/NqtIZipoEZg5ppuctA0DMTIp+IlcXx4Tg1N2IWX6s= +github.com/markbates/cleo v0.0.0-20240313030849-949830e20db3 h1:DL5cdEA9XZXn9sCdflvAneW2DAngKgBzGmzL/ah5PlY= +github.com/markbates/cleo v0.0.0-20240313030849-949830e20db3/go.mod h1:aBLUc128teQ9d5+++pa+hmRxF0+Ka3d8SWXEVu9GT8c= github.com/markbates/fsx v1.3.0 h1:eunGc5BKa7ELGDnsN1Fe8LBH1/ZSeDmAbqIx2DAQRtM= github.com/markbates/fsx v1.3.0/go.mod h1:t7HbKJBmGY9+Wz+4kZI+67Utu3vYLcxKMjfUzz/eOA4= -github.com/markbates/garlic v1.0.0 h1:IOsPWAMbH2p/jnh2OYXTous891NSAkXQdosToJvlg+E= -github.com/markbates/garlic v1.0.0/go.mod h1:k4nxVa4o0HPTVgFiL6IZV8JAfJP9xXqxOkbzEZWO+oQ= +github.com/markbates/garlic v1.1.0 h1:hKGzy51xAnXsLXqbxZrjJTl6LCGIm977xdPK7E1S5ms= +github.com/markbates/garlic v1.1.0/go.mod h1:hPIdI7EYjbnhpj2AIGYg32YH7k+JUhnMd9L17M3INkM= github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d h1:+2OKR5x2iAJTQ2/u8Uyk1hOnJ8pneNV298dhJ0DO0nU= github.com/markbates/hepa v0.0.0-20211129002629-856d16f89b9d/go.mod h1:YCs1lt0wCv6j/HTzT2V/bUWKgdXlOXwTz0118HvMGAo= github.com/markbates/iox v1.0.0 h1:jbg1H1DH1U9yPJ5WxdRw9zl8B4hHg9/xwe4+yLXgLY0= github.com/markbates/iox v1.0.0/go.mod h1:q+P6BLqC21cbcmL82OdIO3A9VFCjq9fRQ+ije7T85ow= -github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e h1:PXixirD5fy4dEyPw1P97LWBwxueR+OTDM1BtcrFgOIU= -github.com/markbates/plugins v0.0.0-20240228174810-34b6b949cf9e/go.mod h1:iBZ9agLtjGRUflFuIntKen8W0EUuU9sDG9j05uX3GuU= +github.com/markbates/plugins v1.1.0 h1:ruPPMnGOnYffVkRE/C6IQS7AKLc3vP4abemkYEeNSp0= +github.com/markbates/plugins v1.1.0/go.mod h1:X2NnUeaBnHd9a9S98HH+pkIHd/Xc3TYKEDWmGEAMQ3o= github.com/markbates/sweets v0.0.0-20210926032915-062eb9bcc0e5 h1:od8GvggTptD2HUz8nGaQQe6n1zAHDbsG+82hfHPNExY= github.com/markbates/sweets v0.0.0-20210926032915-062eb9bcc0e5/go.mod h1:NMNrJiINR9aeBgn5wfzZMJOnwWnDaj4hDOGpGoVV3XE= github.com/markbates/syncx v1.5.1 h1:Kv0hrHUOU0FQ27QgiYf2SDo0JSQ04KcaLysyOtBYrcY= @@ -43,6 +45,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= From d026f10ea79f2075f04e654787a6492ff6102a86 Mon Sep 17 00:00:00 2001 From: Cory LaNou Date: Tue, 10 Sep 2024 14:48:03 -0500 Subject: [PATCH 13/14] move hype.md to root and update workflow --- {.hype/actions => .github/workflows}/hype.md | 0 .github/workflows/hype.yml | 6 +- .hype/actions/hype.yml | 30 - README.md | 977 +++++++++++++++++- {.hype => docs}/badges.md | 0 {.hype => docs}/license.md | 0 {.hype => docs}/quickstart/hype.md | 18 +- {.hype => docs}/quickstart/includes.md | 0 {.hype => docs}/quickstart/src/broken/main.go | 0 {.hype => docs}/quickstart/src/hello/main.go | 0 .hype/hype.md => hype.md | 10 +- 11 files changed, 950 insertions(+), 91 deletions(-) rename {.hype/actions => .github/workflows}/hype.md (100%) delete mode 100644 .hype/actions/hype.yml rename {.hype => docs}/badges.md (100%) rename {.hype => docs}/license.md (100%) rename {.hype => docs}/quickstart/hype.md (90%) rename {.hype => docs}/quickstart/includes.md (100%) rename {.hype => docs}/quickstart/src/broken/main.go (100%) rename {.hype => docs}/quickstart/src/hello/main.go (100%) rename .hype/hype.md => hype.md (85%) diff --git a/.hype/actions/hype.md b/.github/workflows/hype.md similarity index 100% rename from .hype/actions/hype.md rename to .github/workflows/hype.md diff --git a/.github/workflows/hype.yml b/.github/workflows/hype.yml index 29de8e7..e7ab556 100644 --- a/.github/workflows/hype.yml +++ b/.github/workflows/hype.yml @@ -1,6 +1,5 @@ name: Generate README with Hype on: [pull_request] - jobs: build: runs-on: ubuntu-latest @@ -14,13 +13,10 @@ jobs: with: go-version: "1.22.x" cache-dependency-path: subdir/go.sum - - name: Install hype run: go install github.com/gopherguides/hype/cmd/hype@latest - - name: Run hype - run: pushd .hype;hype export -format=markdown -f hype.md > ../README.md;popd - + run: hype export -format=markdown -f hype.md > README.md - name: Commit README back to the repo run: |- git rev-parse --abbrev-ref HEAD diff --git a/.hype/actions/hype.yml b/.hype/actions/hype.yml deleted file mode 100644 index 29de8e7..0000000 --- a/.hype/actions/hype.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Generate README with Hype -on: [pull_request] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.22.x" - cache-dependency-path: subdir/go.sum - - - name: Install hype - run: go install github.com/gopherguides/hype/cmd/hype@latest - - - name: Run hype - run: pushd .hype;hype export -format=markdown -f hype.md > ../README.md;popd - - - name: Commit README back to the repo - run: |- - git rev-parse --abbrev-ref HEAD - git config user.name 'GitHub Actions' - git config user.email 'actions@github.com' - git diff --quiet || (git add README.md && git commit -am "Updated README") - git push origin ${{github.event.pull_request.head.ref}} diff --git a/README.md b/README.md index 7d2d0a8..2da59b8 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Hype is a content generation tool that use traditional Markdown syntax, and allows it to be extended for almost any use to create dynamic, rich, automated output that is easily maintainable and reusable. -Hype follows the same principals that we use for coding; +Hype follows the same principals that we use for coding: * packages (keep relevant content in small, reusable packages, with all links relative to the package) @@ -62,7 +62,7 @@ import "fmt" // snippet: example func main() { - fmt.Println("Hello World") + fmt.Println("Hello World") } // snippet: example @@ -83,8 +83,10 @@ func main() { fmt.Println("Hello World") } ``` +> *source: docs/quickstart/src/hello/main.go:example* + -A `snippet` is not required in your `code` tag. They default behavior of a `code` tag is to include the entire source file. +A `snippet` is not required in your `code` tag. The default behavior of a `code` tag is to include the entire source file. If we leave the tag out, it will result in the following code being included: @@ -96,9 +98,9 @@ import "fmt" func main() { fmt.Println("Hello World") } - - ``` +> *source: docs/quickstart/src/hello/main.go* + Notice that none of the `snippet` comments were in the output? This is because hype recognizes them as directives for the document, and will not show them in the actual output. @@ -125,7 +127,7 @@ $ go run . Hello World -------------------------------------------------------------------------------- -Go Version: go1.22.0 +Go Version: go1.23.0 ``` @@ -146,9 +148,9 @@ import "fmt" func main() { fmt.Println("Hello World") } - - ``` +> *source: docs/quickstart/src/hello/main.go* + --- @@ -158,7 +160,7 @@ $ go run . Hello World -------------------------------------------------------------------------------- -Go Version: go1.22.0 +Go Version: go1.23.0 ``` @@ -176,6 +178,8 @@ func main() { fmt.Println("Hello World") } ``` +> *source: docs/quickstart/src/hello/main.go#example:example* + --- @@ -185,7 +189,7 @@ $ go run . Hello World -------------------------------------------------------------------------------- -Go Version: go1.22.0 +Go Version: go1.23.0 ``` @@ -203,17 +207,19 @@ func main() { fmt.Prin("Hello World") } ``` +> *source: docs/quickstart/src/broken/main.go#example:example* + --- ```shell $ go run . -# github.com/gopherguides/hype/.hype/. +# github.com/gopherguides/hype/. ./main.go:7:6: undefined: fmt.Prin -------------------------------------------------------------------------------- -Go Version: go1.22.0 +Go Version: go1.23.0 ``` @@ -250,7 +256,7 @@ type Context interface{ ... } func WithoutCancel(parent Context) Context -------------------------------------------------------------------------------- -Go Version: go1.22.0 +Go Version: go1.23.0 ``` @@ -273,7 +279,7 @@ func WithCancel(parent Context) (ctx Context, cancel CancelFunc) call cancel as soon as the operations running in this Context complete. -------------------------------------------------------------------------------- -Go Version: go1.22.0 +Go Version: go1.23.0 ``` @@ -311,19 +317,19 @@ There are several options for running the `hype` command. Most notable is the `e Usage of hype: -f string - optional file name to preview, if not provided, defaults to hype.md (default "hype.md") + optional file name to preview, if not provided, defaults to hype.md (default "hype.md") -format string - content type to export to: markdown, html (default "markdown") + content type to export to: markdown, html (default "markdown") -timeout duration - timeout for execution, defaults to 30 seconds (30s) (default 5s) - -v enable verbose output for debugging + timeout for execution, defaults to 30 seconds (30s) (default 5s) + -v enable verbose output for debugging Usage: hype export [options] Examples: - hype export -format html - hype export -f README.md -format html - hype export -f README.md -format markdown -timeout=10s + hype export -format html + hype export -f README.md -format html + hype export -f README.md -format markdown -timeout=10s ` This allows you to see your compiled document either as a single markdown, or as an html document that you can preview in the browser. @@ -340,8 +346,9 @@ The following code will parse the code/code.md and sourceable/sourceable.md docu - ``` +> *source: docs/quickstart/includes.md* + --- @@ -355,22 +362,911 @@ Here is the current structure that we are using to create this readme: $ tree . -├── actions -│   ├── hype.md -│   └── hype.yml -├── badges.md +├── Makefile +├── README.md +├── atom.go +├── atomx +│   ├── atoms.go +│   ├── atoms.ts +│   ├── atomx.go +│   ├── atomx_test.go +│   └── gen.go +├── attributes.go +├── attributes_test.go +├── binding +│   ├── errors.go +│   ├── part.go +│   ├── part_test.go +│   ├── testdata +│   │   ├── toc +│   │   │   ├── 01-one +│   │   │   │   ├── assets +│   │   │   │   │   └── foo.png +│   │   │   │   ├── hype.md +│   │   │   │   ├── hype.tex.gold +│   │   │   │   ├── simple +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── simple.md +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   └── src +│   │   │   │   └── greet +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   ├── 02-two +│   │   │   │   ├── assets +│   │   │   │   │   └── foo.png +│   │   │   │   ├── hype.md +│   │   │   │   ├── hype.tex.gold +│   │   │   │   ├── simple +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── simple.md +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   └── src +│   │   │   │   └── greet +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── 03-three +│   │   │   ├── assets +│   │   │   │   └── foo.png +│   │   │   ├── hype.md +│   │   │   ├── hype.tex.gold +│   │   │   ├── simple +│   │   │   │   ├── assets +│   │   │   │   │   └── foo.png +│   │   │   │   ├── simple.md +│   │   │   │   └── src +│   │   │   │   └── greet +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── src +│   │   │   └── greet +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   └── whole +│   │   └── simple +│   │   ├── 01-one +│   │   │   └── hype.md +│   │   ├── 02-two +│   │   │   └── hype.md +│   │   └── 03-three +│   │   └── hype.md +│   ├── whole.go +│   └── whole_test.go +├── body.go +├── body_test.go +├── cmd +│   └── hype +│   ├── cli +│   │   ├── binding.go +│   │   ├── binding_test.go +│   │   ├── cli.go +│   │   ├── cli_darwin.go +│   │   ├── commander.go +│   │   ├── encode.go +│   │   ├── encode_test.go +│   │   ├── env.go +│   │   ├── env_test.go +│   │   ├── export.go +│   │   ├── marked.go +│   │   ├── marked_test.go +│   │   ├── parser.go +│   │   ├── pwd.go +│   │   ├── slides.go +│   │   ├── testdata +│   │   │   ├── encode +│   │   │   │   └── json +│   │   │   │   ├── hype.md +│   │   │   │   └── success +│   │   │   │   ├── execute-file.json +│   │   │   │   └── parse-file.json +│   │   │   ├── latex +│   │   │   │   ├── file +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── hype.tex.gold +│   │   │   │   │   ├── index.md +│   │   │   │   │   ├── simple +│   │   │   │   │   │   ├── assets +│   │   │   │   │   │   │   └── foo.png +│   │   │   │   │   │   ├── simple.md +│   │   │   │   │   │   └── src +│   │   │   │   │   │   └── greet +│   │   │   │   │   │   ├── go.mod +│   │   │   │   │   │   └── main.go +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   ├── multi +│   │   │   │   │   ├── one +│   │   │   │   │   │   ├── assets +│   │   │   │   │   │   │   └── foo.png +│   │   │   │   │   │   ├── hype.md +│   │   │   │   │   │   ├── hype.tex.gold +│   │   │   │   │   │   ├── simple +│   │   │   │   │   │   │   ├── assets +│   │   │   │   │   │   │   │   └── foo.png +│   │   │   │   │   │   │   ├── simple.md +│   │   │   │   │   │   │   └── src +│   │   │   │   │   │   │   └── greet +│   │   │   │   │   │   │   ├── go.mod +│   │   │   │   │   │   │   └── main.go +│   │   │   │   │   │   └── src +│   │   │   │   │   │   └── greet +│   │   │   │   │   │   ├── go.mod +│   │   │   │   │   │   └── main.go +│   │   │   │   │   ├── three +│   │   │   │   │   │   ├── assets +│   │   │   │   │   │   │   └── foo.png +│   │   │   │   │   │   ├── hype.md +│   │   │   │   │   │   ├── hype.tex.gold +│   │   │   │   │   │   ├── simple +│   │   │   │   │   │   │   ├── assets +│   │   │   │   │   │   │   │   └── foo.png +│   │   │   │   │   │   │   ├── simple.md +│   │   │   │   │   │   │   └── src +│   │   │   │   │   │   │   └── greet +│   │   │   │   │   │   │   ├── go.mod +│   │   │   │   │   │   │   └── main.go +│   │   │   │   │   │   └── src +│   │   │   │   │   │   └── greet +│   │   │   │   │   │   ├── go.mod +│   │   │   │   │   │   └── main.go +│   │   │   │   │   └── two +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── hype.md +│   │   │   │   │   ├── hype.tex.gold +│   │   │   │   │   ├── simple +│   │   │   │   │   │   ├── assets +│   │   │   │   │   │   │   └── foo.png +│   │   │   │   │   │   ├── simple.md +│   │   │   │   │   │   └── src +│   │   │   │   │   │   └── greet +│   │   │   │   │   │   ├── go.mod +│   │   │   │   │   │   └── main.go +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   └── simple +│   │   │   │   ├── assets +│   │   │   │   │   └── foo.png +│   │   │   │   ├── hype.md +│   │   │   │   ├── hype.tex.gold +│   │   │   │   ├── simple +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── simple.md +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   └── src +│   │   │   │   └── greet +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── whole +│   │   │   └── simple +│   │   │   ├── 01-one +│   │   │   │   └── hype.md +│   │   │   ├── 02-two +│   │   │   │   └── hype.md +│   │   │   └── 03-three +│   │   │   └── hype.md +│   │   ├── toc.go +│   │   ├── toc_test.go +│   │   └── vscode.go +│   └── main.go +├── cmd.go +├── cmd_error.go +├── cmd_error_test.go +├── cmd_result.go +├── cmd_result_test.go +├── cmd_test.go +├── code.go +├── code_test.go +├── comment.go +├── comment_test.go +├── dist +│   ├── CHANGELOG.md +│   ├── artifacts.json +│   ├── config.yaml +│   ├── hype_0.1.0_checksums.txt +│   ├── hype_Darwin_arm64.tar.gz +│   ├── hype_Darwin_x86_64.tar.gz +│   ├── hype_Linux_arm64.tar.gz +│   ├── hype_Linux_i386.tar.gz +│   ├── hype_Linux_x86_64.tar.gz +│   ├── hype_Windows_arm64.zip +│   ├── hype_Windows_i386.zip +│   ├── hype_Windows_x86_64.zip +│   ├── hype_darwin_amd64_v1 +│   │   └── hype +│   ├── hype_darwin_arm64 +│   │   └── hype +│   ├── hype_linux_386 +│   │   └── hype +│   ├── hype_linux_amd64_v1 +│   │   └── hype +│   ├── hype_linux_arm64 +│   │   └── hype +│   ├── hype_windows_386 +│   │   └── hype.exe +│   ├── hype_windows_amd64_v1 +│   │   └── hype.exe +│   ├── hype_windows_arm64 +│   │   └── hype.exe +│   └── metadata.json +├── docs +│   ├── badges.md +│   ├── license.md +│   └── quickstart +│   ├── hype.md +│   ├── includes.md +│   └── src +│   ├── broken +│   │   └── main.go +│   └── hello +│   └── main.go +├── document.go +├── document_test.go +├── element.go +├── element_test.go +├── empty.go +├── empty_test.go +├── errors.go +├── execute.go +├── execute_error.go +├── execute_error_test.go +├── execute_test.go +├── fenced_code.go +├── fenced_code_test.go +├── figcaption.go +├── figcaption_test.go +├── figure.go +├── figure_test.go +├── finders.go +├── finders_test.go +├── go.mod +├── go.sum +├── godoc.go +├── golang.go +├── golang_test.go +├── heading.go +├── heading_test.go +├── hype.go ├── hype.md +├── hype_test.go +├── image.go +├── image_test.go +├── include.go +├── include_test.go +├── inline_code.go +├── inline_code_test.go +├── internal +│   └── lone +│   ├── ranger.go +│   └── ranger_test.go +├── li.go +├── li_test.go ├── license.md -└── quickstart - ├── hype.md - ├── includes.md - └── src - ├── broken - │   └── main.go - └── hello - └── main.go - -5 directories, 9 files +├── link.go +├── link_test.go +├── md.go +├── md_test.go +├── mdx +│   ├── parser.go +│   ├── parser_test.go +│   └── testdata +│   ├── assignment.md +│   ├── basics.md +│   ├── booleans.md +│   ├── constants.md +│   ├── hype.md +│   ├── numbers.md +│   ├── src +│   │   ├── constants +│   │   │   ├── const +│   │   │   │   └── main.go +│   │   │   ├── const-err +│   │   │   │   └── main.go +│   │   │   ├── const-infer +│   │   │   │   └── main.go +│   │   │   └── const_type +│   │   │   └── main.go +│   │   ├── go.mod +│   │   ├── numbers +│   │   │   ├── maxuint8 +│   │   │   │   └── main.go +│   │   │   ├── maxuint8-overflow +│   │   │   │   └── main.go +│   │   │   └── maxuint8-saturation +│   │   │   └── main.go +│   │   ├── utf8 +│   │   │   ├── utf8 +│   │   │   │   └── main.go +│   │   │   ├── utf8-loop +│   │   │   │   └── main.go +│   │   │   ├── utf8-range +│   │   │   │   └── main.go +│   │   │   └── utf8-rune +│   │   │   └── main.go +│   │   └── variables +│   │   ├── multiple +│   │   │   └── main.go +│   │   └── zero +│   │   └── main.go +│   ├── strings.md +│   ├── utf8.md +│   └── variables.md +├── metadata.go +├── metadata_test.go +├── node.go +├── node_test.go +├── now.go +├── now_test.go +├── ol.go +├── ol_test.go +├── page.go +├── page_test.go +├── paragraph.go +├── paragraph_test.go +├── parse_error.go +├── parse_error_test.go +├── parser.go +├── parser_test.go +├── post_execute.go +├── post_execute_error.go +├── post_execute_error_test.go +├── post_execute_test.go +├── post_parse_error.go +├── post_parse_error_test.go +├── post_parser.go +├── post_parser_test.go +├── pre_execute.go +├── pre_execute_error.go +├── pre_execute_error_test.go +├── pre_execute_test.go +├── pre_parse_error.go +├── pre_parse_error_test.go +├── pre_parser.go +├── pre_parser_test.go +├── ref.go +├── ref_processor.go +├── ref_processor_test.go +├── ref_test.go +├── references_test.go +├── restripe_figures.go +├── revive.toml +├── slides +│   ├── app.go +│   └── templates +│   ├── assets +│   │   ├── app.css +│   │   └── app.js +│   └── slides.html +├── snippet.go +├── snippet_test.go +├── source_code.go +├── source_code_test.go +├── table.go +├── table_test.go +├── tag.go +├── td.go +├── td_test.go +├── testdata +│   ├── auto +│   │   ├── blockquote +│   │   │   ├── html +│   │   │   │   ├── hype.gold +│   │   │   │   ├── hype.md +│   │   │   │   └── shine.txt +│   │   │   └── md +│   │   │   ├── hype.gold +│   │   │   ├── hype.md +│   │   │   └── shine.txt +│   │   ├── commands +│   │   │   ├── greet +│   │   │   │   ├── hype.gold +│   │   │   │   ├── hype.md +│   │   │   │   └── src +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   ├── results +│   │   │   │   ├── data +│   │   │   │   │   ├── hype.gold +│   │   │   │   │   └── hype.md +│   │   │   │   └── truncate +│   │   │   │   ├── hype.gold +│   │   │   │   ├── hype.md +│   │   │   │   └── src +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   ├── side-by-side +│   │   │   │   ├── hype.gold +│   │   │   │   ├── hype.md +│   │   │   │   └── values +│   │   │   │   ├── _string.md +│   │   │   │   ├── assets +│   │   │   │   │   └── string-keys.svg +│   │   │   │   ├── src +│   │   │   │   │   └── string-keys +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   └── values.md +│   │   │   └── timeout +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── metadata +│   │   │   └── simple +│   │   │   ├── hype.gold +│   │   │   └── hype.md +│   │   ├── parser +│   │   │   └── hello +│   │   │   ├── hype.gold +│   │   │   ├── hype.md +│   │   │   └── second +│   │   │   ├── second.md +│   │   │   └── src +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── refs +│   │   │   ├── fenced +│   │   │   │   ├── hype.gold +│   │   │   │   └── hype.md +│   │   │   ├── figure-styles +│   │   │   │   ├── hype.gold +│   │   │   │   └── hype.md +│   │   │   ├── images +│   │   │   │   ├── assets +│   │   │   │   │   └── nodes.svg +│   │   │   │   ├── hype.gold +│   │   │   │   └── hype.md +│   │   │   ├── includes +│   │   │   │   ├── assets +│   │   │   │   │   └── foo.png +│   │   │   │   ├── hype.gold +│   │   │   │   ├── hype.md +│   │   │   │   ├── simple +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── simple.md +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   └── src +│   │   │   │   └── greet +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── simple +│   │   │   ├── assets +│   │   │   │   └── foo.png +│   │   │   ├── hype.gold +│   │   │   ├── hype.md +│   │   │   └── src +│   │   │   └── greet +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── snippets +│   │   │   ├── range +│   │   │   │   ├── hype.gold +│   │   │   │   ├── hype.md +│   │   │   │   └── src +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── simple +│   │   │   ├── hype.gold +│   │   │   ├── hype.md +│   │   │   └── src +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── toc +│   │   │   ├── hype.gold +│   │   │   └── hype.md +│   │   └── vars +│   │   ├── details +│   │   │   ├── hype.gold +│   │   │   └── hype.md +│   │   ├── metadata +│   │   │   ├── hype.gold +│   │   │   └── hype.md +│   │   └── var_tag +│   │   ├── hype.gold +│   │   └── hype.md +│   ├── commands +│   │   └── bad-exit +│   │   ├── go.mod +│   │   └── main.go +│   ├── doc +│   │   ├── execution +│   │   │   ├── failure +│   │   │   │   └── hype.md +│   │   │   ├── nested_failure +│   │   │   │   ├── hype.md +│   │   │   │   └── second +│   │   │   │   ├── second.md +│   │   │   │   └── src +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── success +│   │   │   └── hype.md +│   │   ├── pages +│   │   │   ├── hype.md +│   │   │   └── second +│   │   │   ├── second.md +│   │   │   └── src +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── simple +│   │   │   └── hype.md +│   │   ├── snippets +│   │   │   ├── hype.md +│   │   │   └── src +│   │   │   └── main.ts +│   │   └── to_md +│   │   ├── basics +│   │   │   ├── basics.md +│   │   │   └── src +│   │   │   └── background +│   │   │   ├── empty +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── implementation +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── cancellation +│   │   │   ├── assets +│   │   │   │   ├── cancellation.svg +│   │   │   │   └── nodes.svg +│   │   │   ├── cancellation.md +│   │   │   └── src +│   │   │   ├── basic +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── cancelling +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── errors +│   │   │   ├── errors.md +│   │   │   └── src +│   │   │   ├── canceled +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── deadline +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── graffles +│   │   │   └── context.graffle +│   │   ├── hype.gold +│   │   ├── hype.md +│   │   ├── nodes +│   │   │   ├── assets +│   │   │   │   └── nodes.svg +│   │   │   ├── nodes.md +│   │   │   └── src +│   │   │   └── node-tree +│   │   │   ├── go.mod +│   │   │   ├── go.sum +│   │   │   ├── main.go +│   │   │   └── stdout.txt +│   │   ├── rules +│   │   │   └── rules.md +│   │   ├── signals +│   │   │   ├── signals.md +│   │   │   └── src +│   │   │   ├── signals +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── testing +│   │   │   ├── go.mod +│   │   │   ├── go.sum +│   │   │   ├── signals.go +│   │   │   ├── signals_test.go +│   │   │   └── stdout.txt +│   │   ├── timeouts +│   │   │   ├── src +│   │   │   │   ├── timeout +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   ├── with-deadline +│   │   │   │   │   ├── go.mod +│   │   │   │   │   ├── go.sum +│   │   │   │   │   └── main.go +│   │   │   │   └── with-timeout +│   │   │   │   ├── go.mod +│   │   │   │   ├── go.sum +│   │   │   │   └── main.go +│   │   │   └── timeouts.md +│   │   └── values +│   │   ├── _securing.md +│   │   ├── _strings.md +│   │   ├── assets +│   │   │   └── string-keys.svg +│   │   ├── src +│   │   │   ├── basic +│   │   │   │   ├── go.mod +│   │   │   │   ├── go.sum +│   │   │   │   └── main.go +│   │   │   ├── custom-const +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   ├── custom-keys +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   ├── keys +│   │   │   │   ├── go.mod +│   │   │   │   ├── main.go +│   │   │   │   └── stdout.txt +│   │   │   ├── malicious +│   │   │   │   ├── bar +│   │   │   │   │   └── bar.go +│   │   │   │   ├── foo +│   │   │   │   │   └── foo.go +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   ├── resolution +│   │   │   │   ├── go.mod +│   │   │   │   ├── go.sum +│   │   │   │   ├── main.go +│   │   │   │   └── stdout.txt +│   │   │   ├── secured +│   │   │   │   ├── bar +│   │   │   │   │   └── bar.go +│   │   │   │   ├── foo +│   │   │   │   │   └── foo.go +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── string-keys +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   └── values.md +│   ├── golang +│   │   └── sym +│   │   ├── cmd +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── go.mod +│   │   └── sym.go +│   ├── includes +│   │   ├── broken +│   │   │   └── hype.md +│   │   ├── sublevel +│   │   │   ├── below +│   │   │   │   └── b.md +│   │   │   └── hype.md +│   │   └── toplevel +│   │   └── hype.md +│   ├── json +│   │   ├── body.json +│   │   ├── cmd.json +│   │   ├── cmd_error.json +│   │   ├── cmd_result.json +│   │   ├── comment.json +│   │   ├── document.json +│   │   ├── element.json +│   │   ├── execute_error.json +│   │   ├── fenced_code.json +│   │   ├── figcaption.json +│   │   ├── figure.json +│   │   ├── heading.json +│   │   ├── image.json +│   │   ├── include.json +│   │   ├── inline_code.json +│   │   ├── li.json +│   │   ├── link.json +│   │   ├── metadata.json +│   │   ├── now.json +│   │   ├── ol.json +│   │   ├── p.json +│   │   ├── page.json +│   │   ├── parse_error.json +│   │   ├── parser.json +│   │   ├── post_execute_error.json +│   │   ├── post_parse_error.json +│   │   ├── pre_execute_error.json +│   │   ├── pre_parse_error.json +│   │   ├── ref.json +│   │   ├── table.json +│   │   ├── td.json +│   │   ├── th.json +│   │   ├── thead.json +│   │   ├── toc.json +│   │   ├── tr.json +│   │   ├── ul.json +│   │   └── var.json +│   ├── markdown +│   │   └── unknown-atom +│   │   ├── _included.md +│   │   └── hype.md +│   ├── metadata +│   │   ├── multi +│   │   │   └── hype.md +│   │   └── pages +│   │   └── hype.md +│   ├── now +│   │   ├── hype.gold +│   │   └── hype.md +│   ├── parser +│   │   ├── errors +│   │   │   ├── execute +│   │   │   │   └── hype.md +│   │   │   ├── folder +│   │   │   │   ├── 01-one +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── hype.md +│   │   │   │   │   ├── hype.tex.gold +│   │   │   │   │   ├── simple +│   │   │   │   │   │   ├── assets +│   │   │   │   │   │   │   └── foo.png +│   │   │   │   │   │   ├── simple.md +│   │   │   │   │   │   └── src +│   │   │   │   │   │   └── greet +│   │   │   │   │   │   ├── go.mod +│   │   │   │   │   │   └── main.go +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   ├── 02-two +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── hype.md +│   │   │   │   │   ├── hype.tex.gold +│   │   │   │   │   ├── simple +│   │   │   │   │   │   ├── assets +│   │   │   │   │   │   │   └── foo.png +│   │   │   │   │   │   ├── simple.md +│   │   │   │   │   │   └── src +│   │   │   │   │   │   └── greet +│   │   │   │   │   │   ├── go.mod +│   │   │   │   │   │   └── main.go +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   └── 03-three +│   │   │   │   ├── assets +│   │   │   │   │   └── foo.png +│   │   │   │   ├── hype.md +│   │   │   │   ├── hype.tex.gold +│   │   │   │   ├── simple +│   │   │   │   │   ├── assets +│   │   │   │   │   │   └── foo.png +│   │   │   │   │   ├── simple.md +│   │   │   │   │   └── src +│   │   │   │   │   └── greet +│   │   │   │   │   ├── go.mod +│   │   │   │   │   └── main.go +│   │   │   │   └── src +│   │   │   │   └── greet +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   ├── post_execute +│   │   │   │   └── hype.md +│   │   │   ├── post_parse +│   │   │   │   └── hype.md +│   │   │   ├── pre_execute +│   │   │   │   └── hype.md +│   │   │   └── pre_parse +│   │   │   └── hype.md +│   │   └── folder +│   │   ├── 01-one +│   │   │   ├── assets +│   │   │   │   └── foo.png +│   │   │   ├── hype.md +│   │   │   ├── hype.tex.gold +│   │   │   ├── simple +│   │   │   │   ├── assets +│   │   │   │   │   └── foo.png +│   │   │   │   ├── simple.md +│   │   │   │   └── src +│   │   │   │   └── greet +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── src +│   │   │   └── greet +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   ├── 02-two +│   │   │   ├── assets +│   │   │   │   └── foo.png +│   │   │   ├── hype.md +│   │   │   ├── hype.tex.gold +│   │   │   ├── simple +│   │   │   │   ├── assets +│   │   │   │   │   └── foo.png +│   │   │   │   ├── simple.md +│   │   │   │   └── src +│   │   │   │   └── greet +│   │   │   │   ├── go.mod +│   │   │   │   └── main.go +│   │   │   └── src +│   │   │   └── greet +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   └── 03-three +│   │   ├── assets +│   │   │   └── foo.png +│   │   ├── hype.md +│   │   ├── hype.tex.gold +│   │   ├── simple +│   │   │   ├── assets +│   │   │   │   └── foo.png +│   │   │   ├── simple.md +│   │   │   └── src +│   │   │   └── greet +│   │   │   ├── go.mod +│   │   │   └── main.go +│   │   └── src +│   │   └── greet +│   │   ├── go.mod +│   │   └── main.go +│   ├── snippets +│   │   ├── snip.txt +│   │   ├── snippets.go +│   │   ├── snippets.html +│   │   ├── snippets.js +│   │   └── snippets.rb +│   ├── table +│   │   ├── data +│   │   │   └── hype.md +│   │   ├── headless +│   │   │   ├── hype.gold +│   │   │   └── hype.md +│   │   ├── md_in_html +│   │   │   ├── hype.gold +│   │   │   └── hype.md +│   │   └── md_in_md +│   │   ├── hype.gold +│   │   └── hype.md +│   ├── to_md +│   │   └── source_code +│   │   ├── full +│   │   │   ├── hype.gold +│   │   │   ├── hype.md +│   │   │   └── src +│   │   │   └── main.go +│   │   └── snippet +│   │   ├── hype.gold +│   │   ├── hype.md +│   │   └── src +│   │   └── main.go +│   └── toc +│   ├── hype.gold +│   └── hype.md +├── text.go +├── th.go +├── th_test.go +├── thead.go +├── thead_test.go +├── time.go +├── title.go +├── title_test.go +├── tmpl.go +├── tmpl_test.go +├── toc.go +├── toc_test.go +├── tr.go +├── tr_test.go +├── type.go +├── ul.go +├── ul_test.go +├── unwrap.go +├── var.go +└── var_test.go + +322 directories, 581 files ``` --- @@ -406,7 +1302,6 @@ The current action is set to only generate the readme on a pull request and comm ```yml name: Generate README with Hype on: [pull_request] - jobs: build: runs-on: ubuntu-latest @@ -420,13 +1315,10 @@ jobs: with: go-version: "1.22.x" cache-dependency-path: subdir/go.sum - - name: Install hype run: go install github.com/gopherguides/hype/cmd/hype@latest - - name: Run hype - run: pushd .hype;hype export -format=markdown -f hype.md > ../README.md;popd - + run: hype export -format=markdown -f hype.md > README.md - name: Commit README back to the repo run: |- git rev-parse --abbrev-ref HEAD @@ -434,8 +1326,9 @@ jobs: git config user.email 'actions@github.com' git diff --quiet || (git add README.md && git commit -am "Updated README") git push origin ${{github.event.pull_request.head.ref}} - ``` +> *source: .github/workflows/hype.yml* + --- diff --git a/.hype/badges.md b/docs/badges.md similarity index 100% rename from .hype/badges.md rename to docs/badges.md diff --git a/.hype/license.md b/docs/license.md similarity index 100% rename from .hype/license.md rename to docs/license.md diff --git a/.hype/quickstart/hype.md b/docs/quickstart/hype.md similarity index 90% rename from .hype/quickstart/hype.md rename to docs/quickstart/hype.md index dcc7071..39e1007 100644 --- a/.hype/quickstart/hype.md +++ b/docs/quickstart/hype.md @@ -25,7 +25,7 @@ import "fmt" // snippet: example func main() { - fmt.Println("Hello World") + fmt.Println("Hello World") } // snippet: example @@ -43,7 +43,7 @@ The output of including that tag will be as follows: -A `snippet` is not required in your `code` tag. They default behavior of a `code` tag is to include the entire source file. +A `snippet` is not required in your `code` tag. The default behavior of a `code` tag is to include the entire source file. If we leave the tag out, it will result in the following code being included: @@ -153,19 +153,19 @@ $ hype export -h Usage of hype: -f string - optional file name to preview, if not provided, defaults to hype.md (default "hype.md") + optional file name to preview, if not provided, defaults to hype.md (default "hype.md") -format string - content type to export to: markdown, html (default "markdown") + content type to export to: markdown, html (default "markdown") -timeout duration - timeout for execution, defaults to 30 seconds (30s) (default 5s) - -v enable verbose output for debugging + timeout for execution, defaults to 30 seconds (30s) (default 5s) + -v enable verbose output for debugging Usage: hype export [options] Examples: - hype export -format html - hype export -f README.md -format html - hype export -f README.md -format markdown -timeout=10s + hype export -format html + hype export -f README.md -format html + hype export -f README.md -format markdown -timeout=10s ``` This allows you to see your compiled document either as a single markdown, or as an html document that you can preview in the browser. diff --git a/.hype/quickstart/includes.md b/docs/quickstart/includes.md similarity index 100% rename from .hype/quickstart/includes.md rename to docs/quickstart/includes.md diff --git a/.hype/quickstart/src/broken/main.go b/docs/quickstart/src/broken/main.go similarity index 100% rename from .hype/quickstart/src/broken/main.go rename to docs/quickstart/src/broken/main.go diff --git a/.hype/quickstart/src/hello/main.go b/docs/quickstart/src/hello/main.go similarity index 100% rename from .hype/quickstart/src/hello/main.go rename to docs/quickstart/src/hello/main.go diff --git a/.hype/hype.md b/hype.md similarity index 85% rename from .hype/hype.md rename to hype.md index 5cc063f..7f2f3d3 100644 --- a/.hype/hype.md +++ b/hype.md @@ -1,10 +1,10 @@ - + # Hype Hype is a content generation tool that use traditional Markdown syntax, and allows it to be extended for almost any use to create dynamic, rich, automated output that is easily maintainable and reusable. -Hype follows the same principals that we use for coding; +Hype follows the same principals that we use for coding: - packages (keep relevant content in small, reusable packages, with all links relative to the package) - reuse - write your documentation once (even in your code), and use everywhere (blog, book, github repo, etc) @@ -24,7 +24,7 @@ hype export -format=markdown -f hype.md > ../README.md You can also use a [github action](#using-github-actions-to-update-your-readme) to automatically update your README as well. - + # README Source @@ -34,10 +34,10 @@ Here is the current structure that we are using to create this readme: - + # Issues There are several issues that still need to be worked on. Please see the issues tab if you are interested in helping. - + From ec1e0fb2134269c5aedafbad164f25d8c0b1cd18 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 10 Sep 2024 19:48:38 +0000 Subject: [PATCH 14/14] Updated README --- README.md | 64 +++++++++++-------------------------------------------- 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 2da59b8..9cb5a5b 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,6 @@ func main() { fmt.Println("Hello World") } ``` -> *source: docs/quickstart/src/hello/main.go:example* - A `snippet` is not required in your `code` tag. The default behavior of a `code` tag is to include the entire source file. @@ -98,10 +96,10 @@ import "fmt" func main() { fmt.Println("Hello World") } -``` -> *source: docs/quickstart/src/hello/main.go* +``` + Notice that none of the `snippet` comments were in the output? This is because hype recognizes them as directives for the document, and will not show them in the actual output. # Go Specific Commands @@ -127,7 +125,7 @@ $ go run . Hello World -------------------------------------------------------------------------------- -Go Version: go1.23.0 +Go Version: go1.22.6 ``` @@ -148,10 +146,10 @@ import "fmt" func main() { fmt.Println("Hello World") } -``` -> *source: docs/quickstart/src/hello/main.go* +``` + --- ```shell @@ -160,7 +158,7 @@ $ go run . Hello World -------------------------------------------------------------------------------- -Go Version: go1.23.0 +Go Version: go1.22.6 ``` @@ -178,8 +176,6 @@ func main() { fmt.Println("Hello World") } ``` -> *source: docs/quickstart/src/hello/main.go#example:example* - --- @@ -189,7 +185,7 @@ $ go run . Hello World -------------------------------------------------------------------------------- -Go Version: go1.23.0 +Go Version: go1.22.6 ``` @@ -207,8 +203,6 @@ func main() { fmt.Prin("Hello World") } ``` -> *source: docs/quickstart/src/broken/main.go#example:example* - --- @@ -219,7 +213,7 @@ $ go run . ./main.go:7:6: undefined: fmt.Prin -------------------------------------------------------------------------------- -Go Version: go1.23.0 +Go Version: go1.22.6 ``` @@ -256,7 +250,7 @@ type Context interface{ ... } func WithoutCancel(parent Context) Context -------------------------------------------------------------------------------- -Go Version: go1.23.0 +Go Version: go1.22.6 ``` @@ -279,7 +273,7 @@ func WithCancel(parent Context) (ctx Context, cancel CancelFunc) call cancel as soon as the operations running in this Context complete. -------------------------------------------------------------------------------- -Go Version: go1.23.0 +Go Version: go1.22.6 ``` @@ -346,9 +340,8 @@ The following code will parse the code/code.md and sourceable/sourceable.md docu -``` -> *source: docs/quickstart/includes.md* +``` --- @@ -576,36 +569,6 @@ $ tree ├── code_test.go ├── comment.go ├── comment_test.go -├── dist -│   ├── CHANGELOG.md -│   ├── artifacts.json -│   ├── config.yaml -│   ├── hype_0.1.0_checksums.txt -│   ├── hype_Darwin_arm64.tar.gz -│   ├── hype_Darwin_x86_64.tar.gz -│   ├── hype_Linux_arm64.tar.gz -│   ├── hype_Linux_i386.tar.gz -│   ├── hype_Linux_x86_64.tar.gz -│   ├── hype_Windows_arm64.zip -│   ├── hype_Windows_i386.zip -│   ├── hype_Windows_x86_64.zip -│   ├── hype_darwin_amd64_v1 -│   │   └── hype -│   ├── hype_darwin_arm64 -│   │   └── hype -│   ├── hype_linux_386 -│   │   └── hype -│   ├── hype_linux_amd64_v1 -│   │   └── hype -│   ├── hype_linux_arm64 -│   │   └── hype -│   ├── hype_windows_386 -│   │   └── hype.exe -│   ├── hype_windows_amd64_v1 -│   │   └── hype.exe -│   ├── hype_windows_arm64 -│   │   └── hype.exe -│   └── metadata.json ├── docs │   ├── badges.md │   ├── license.md @@ -1266,7 +1229,7 @@ $ tree ├── var.go └── var_test.go -322 directories, 581 files +313 directories, 560 files ``` --- @@ -1326,9 +1289,8 @@ jobs: git config user.email 'actions@github.com' git diff --quiet || (git add README.md && git commit -am "Updated README") git push origin ${{github.event.pull_request.head.ref}} -``` -> *source: .github/workflows/hype.yml* +``` ---