Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entry point for embed-code-go #33

Merged
merged 68 commits into from
Apr 23, 2024
Merged

Add entry point for embed-code-go #33

merged 68 commits into from
Apr 23, 2024

Conversation

vb-td
Copy link
Collaborator

@vb-td vb-td commented Apr 17, 2024

In this PR the entry point was added.

Now it is possible to run embed-code-go with the two following modes:

  1. Embedding — in this case all docs files are scanned for tags, and all corresponding embeddings are performed.
  2. Checking for up-to-date — in this case all docs files are checked for being up-to-date. If check is failed, an error message with corresponding files listed is provided.

Modes are selected by the mandatory mode argument. If it is set to check, then the checking for up-to-date is performed. If it is set to embed, the embedding is performed.

The tests for CLI functions are provided as well.

Other changes:

  • The case with multi-line embed-code tags was handled;
  • The fault line reading was fixed;
  • The issue with double-starred glob patterns was fixed.

Instruction

The tool can be executed as binary file or as a Go file. In the second case, user must have Go installed. The development version is 1.22.1.

Compiling

For compiling, Go must have been installed as well.
Open terminal and navigate to the directory where embed_code.go is located. Then, use the following command to compile the file:

go build embed_code.go

This will create an executable file named embed_code (or embed_code.exe on Windows) in the same directory.

Usage

To run the embed_code binary executable, the following command can be used:

./embed_code [arguments]

To run the embed_code.go file, the following command can be used:

go run ./embed_code.go [arguments]

The available arguments are:

  • -mode: mandatory, 'check' to checking for code embeddings to be up-to-date; 'embed' to start the embedding process;
  • -code_root: optional, path to the root directory containing code files;
  • -docs_root: optional, path to the root directory containing documentation files;
  • -config_file_path: optional, path to a YAML configuration file that contains the code_root and docs_root fields;
  • -code_includes: optional, a comma-separated string of glob patterns for code files to include. For example: **/*.java,**/*.gradle. Default value is **/*.*;
  • -doc_includes: optional, a comma-separated string of glob patterns for docs files to include. For example: docs/**/*.md,guides/*.html. Default value is **/*.md,**/*.html;
  • -fragments_dir: optional, a path to a directory with code fragments. Default value is ./build/fragments;
  • -separator: optional, a string which is used as a separator between code fragments. Default value is ....

Even though code_root, docs_root, and config_file_path arguments are optional, Embed-code still requires root directories for code and docs to be set. This can be done in two ways:

  1. code_root and docs_root arguments, in this case roots are read directly from provided paths.
  2. config_path argument, in this case roots are read from the given config file.

If both options are missed, the embedding fails. If both options are set, the embedding fails as well.

Examples

go run ./embed_code.go -mode=embed -code_root=C:/Users/username/code -docs_root=C:/Users/username/docs
go run ./embed_code.go -mode=check -config_file_path=C:/Users/username/config.yml
go run ./embed_code.go -mode=check  -code_root=C:/Users/username/code -docs_root=C:/Users/username/docs -doc_includes=docs/**/*.md,guides/*.html

@armiol
Copy link
Collaborator

armiol commented Apr 19, 2024

@vb-td please review your PR description.

  1. I have spent some time and text to describe why the configuration options are not "flags". However, here we go again.
  2. There is "comma", and there is "coma". They are very different.
Screenshot 2024-04-19 at 15 08 34

@armiol
Copy link
Collaborator

armiol commented Apr 20, 2024

@vb-td FYI, I have updated the PR description by using back-ticks where they should be used. Namely, all argument names and values are, by their nature, code. Please keep this in mind next time.

Copy link
Collaborator

@armiol armiol left a comment

Choose a reason for hiding this comment

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

@vb-td LGTM from my side.

Please see the comments from @dmytro-kashcheiev, if any follow.

Copy link
Collaborator

@dmytro-kashcheiev dmytro-kashcheiev left a comment

Choose a reason for hiding this comment

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

@vb-td LGTM with minor comment.

@vb-td vb-td merged commit 0ba3769 into embed-code-go Apr 23, 2024
2 checks passed
@vb-td vb-td deleted the embed-code-go-cli branch April 23, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants