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

Provide code syntax hints/mappings for file extensions #13

Open
centminmod opened this issue Jul 27, 2024 · 3 comments
Open

Provide code syntax hints/mappings for file extensions #13

centminmod opened this issue Jul 27, 2024 · 3 comments

Comments

@centminmod
Copy link

centminmod commented Jul 27, 2024

Sort of inline with #9 to add a feature to allow users to pair custom file extensions with specific code syntax highlighting.

Right now for my code base, I see code2prompt has a lot of wrapped code in unknown syntax highlighting

```unknown

For example, maybe there's a way to tell code2prompt that *.inc extension files have bash shell scripting so when it comes across *.inc extension files code it wraps it in

```bash

Wasn't sure about how that would be done so asked ChatGPT4o 🤓

  1. Define a Command Line Argument for Mappings: Introduce a new command line argument, such as --syntax-map, which takes a list of mappings.
  2. Specify Mappings in a Clear Format: Use a simple and clear format for specifying each mapping, for example, extension:syntax.
  3. Handle Multiple Mappings: Allow users to specify multiple mappings separated by a comma or provide multiple --syntax-map arguments.
code2prompt --syntax-map "inc:bash,customext:python,ext2:javascript"
@raphaelmansuy
Copy link
Owner

Added in the roadmap.

@raphaelmansuy
Copy link
Owner

Will be released soon

@centminmod
Copy link
Author

centminmod commented Oct 26, 2024

I see the readme has this updated usage example but --help for 0.8.1 doesn't show it from pipx install? and --analyze option is gone worked on 0.6.x versions

code2prompt --analyze --path $projectdir --gitignore $gitignoredir --suppress-comments --tokens --encoding $encoding --case-sensitive --output project_summary_analyze.md
Usage: code2prompt [OPTIONS] COMMAND [ARGS]...
Try 'code2prompt --help' for help.

Error: No such option: --analyze
pipx install code2prompt --force
Installing to existing venv 'code2prompt'
  installed package code2prompt 0.8.1, installed using Python 3.9.20
  These apps are now globally available
    - code2prompt
done! ✨ 🌟 ✨
code2prompt --help
Usage: code2prompt [OPTIONS] COMMAND [ARGS]...

  code2prompt CLI tool

Options:
  -v, --version                   Show the version and exit.
  --config FILE                   Path to configuration file
  -p, --path PATH                 Path(s) to the directory or file to process.
  -o, --output PATH               Name of the output Markdown file.
  -g, --gitignore PATH            Path to the .gitignore file.
  -f, --filter TEXT               Comma-separated filter patterns to include
                                  files (e.g., "*.py,*.js").
  -i, --interactive               Interactive mode to select files.
  -e, --exclude TEXT              Comma-separated patterns to exclude files
                                  (e.g., "*.txt,*.md").
  --case-sensitive                Perform case-sensitive pattern matching.
  -s, --suppress-comments         Strip comments from the code files.
  -ln, --line-number              Add line numbers to source code blocks.
  --no-codeblock                  Disable wrapping code inside markdown code
                                  blocks.
  -t, --template PATH             Path to a Jinja2 template file for custom
                                  prompt generation.
  --tokens                        Display the token count of the generated
                                  prompt.
  --encoding [cl100k_base|p50k_base|p50k_edit|r50k_base]
                                  Specify the tokenizer encoding to use.
  --create-templates              Create a templates directory with example
                                  templates.
  --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
                                  Set the logging level.
  --price                         Display the estimated price of tokens based
                                  on provider and model.
  --provider TEXT                 Specify the provider for price calculation.
  --model TEXT                    Specify the model for price calculation.
  --output-tokens INTEGER         Specify the number of output tokens for
                                  price calculation.
  --help                          Show this message and exit.

Commands:
  analyze   Analyze codebase structure
  generate  Generate markdown from code files

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

No branches or pull requests

2 participants