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

Unable to provide custom environment variables for settings values #225

Open
ZachWatkins opened this issue Jul 17, 2022 · 1 comment
Open

Comments

@ZachWatkins
Copy link

ZachWatkins commented Jul 17, 2022

Hi, I really enjoy this extension and I want to automatically include my project's current package name in the "@Package" tag and version number in the "@SInCE" tag for class and function DocBlocks. I'm wondering if there's even a way to do this, I just want to define "@SInCE" at runtime using the results of $ git describe --tags or process.env.version or a version number from the workspace's .env file.

I've included both the environment variable and custom config tags for such variables since it's part of my troubleshooting to see if the value can be loaded from either place.

Here is my PHP DocBlocker config for classes:

../.vscode/settings.json

...
"php-docblocker.classTemplate": {
  "message": {
    "gapAfter": true
  },
  "package": {
    "content": "@package    ${env:PackageName} ${config:package_name}"
  },
  "subpackage": {
    "content": "@subpackage ${RELATIVE_FILEPATH/^([a-z]{1})([^.]+)(\\.php)/${1:/upcase}${2}/}"
  },
  "since": {
    "content": "@since      ${env:PackageVersion} ${config:package_version}"
  },
  "author": {
	  "content": "@author     ${env:AuthorName} ${config:author_name}"
  },
  "copyright": {
	  "content": "@copyright  ${CURRENT_MONTH_NAME} ${CURRENT_DATE}, ${CURRENT_YEAR} ${env:COPYRIGHT_HOLDER} ${config:COPYRIGHT_HOLDER}"
  }
},
...

I have tried loading custom variables in the following places but they are not detected and not replacing the above values in the generated DocBlock.

  1. Powershell user profile
  2. .env file
  3. .envrc file
  4. settings.json as custom configurations at the root level of the settings object.

I'm using Windows 10 and VSCode 1.69.

I even created my own extension in the hopes that I could retrieve this information but with no luck.

Thank you for your time and let me know if you need more information.

@ZachWatkins
Copy link
Author

I've created a pull request: #226

After forking the extension and doing some digging it seems no environment variables are available to extension configuration settings by default and developers must provide this feature independently. The scoped variables like env, config, command, etc seem to only be available to launch.json and tasks.json configurations.

It would be very helpful if I could do git describe --tags and have that be the value of @since tags since that would avoid duplicate work. But because that is very specific I decided against it and implemented a way for this extension to replace environment variable tags in its settings with environment variables available to VS Code's other JSON 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

1 participant