-
-
Notifications
You must be signed in to change notification settings - Fork 275
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 Solidity plugin #1405
Add Solidity plugin #1405
Conversation
Hey @stefanbuck, not sure how to configure the |
This looks outdated, we don't use Travis anymore. It might due to the fact you run the tests from a fork and this might doesn't work. I'll have a closer look at your PR tonight. |
@stefanbuck the e2e instructions are out dated https://github.com/OctoLinker/OctoLinker/tree/2b2c34147fc15099f8059fec0d3953eb8ef0cfa2/e2e#contribution |
@lucaperret there's 2 things missing which is why the tests are failing. The plugin needs to be added to core/package.json and core/load-plugins.js. Once you do that you can use If you're using Node 17 the yarn scripts won't work without first adding |
Locally I run the tests by adding the following code to the export { default as Solidity } from '../plugin-solidity'; As the package isn't published yet, I guessed I shouldn't add it the import as |
These don't get published to npm, webpack will resolve them from the local folder when it bundles everything. These two changes are all you should need to make: index 3199f3a..f5d9d3b 100644
--- a/packages/core/load-plugins.js
+++ b/packages/core/load-plugins.js
@@ -25,6 +25,7 @@ export { default as Ruby } from '@octolinker/plugin-ruby';
export { default as Rust } from '@octolinker/plugin-rust';
export { default as RustCargo } from '@octolinker/plugin-rust-cargo';
export { default as Sass } from '@octolinker/plugin-sass';
+export { default as Solidity } from '@octolinker/plugin-solidity';
export { default as TypeScript } from '@octolinker/plugin-typescript';
export { default as Vim } from '@octolinker/plugin-vim';
export { default as GitHubActions } from '@octolinker/plugin-github-actions'; diff --git a/packages/core/package.json b/packages/core/package.json
index 6c72b41..bbed834 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -43,6 +43,7 @@
"@octolinker/plugin-rust": "1.0.0",
"@octolinker/plugin-rust-cargo": "1.0.0",
"@octolinker/plugin-sass": "1.0.0",
+ "@octolinker/plugin-solidity": "1.0.0",
"@octolinker/plugin-typescript": "1.0.0",
"@octolinker/plugin-vim": "1.0.0",
"@octolinker/user-interface": "1.0.0", |
getPattern() { | ||
return { | ||
pathRegexes: [/\.sol$/], | ||
githubClasses: ['type-solidity', 'highlight-source-solidity'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefanbuck is the build failing because this is set but no example exists for it in /packages/blob-reader/fixtures/github.com/issue/code.html?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I remember yes. This HTML is just the output from OctoLinker/testrepo#2. I added a solidity snippet at the end which should make this test pass. The fixture are updated on each CI run https://github.com/OctoLinker/OctoLinker/blob/main/packages/blob-reader/scripts/update-fixtures.sh. Just for debugging purpose we store the output within the repo. I'll take care of updating the fixture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefanbuck you missed the ".sol" extension I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefanbuck without the Will the code snippet support even do anything with this plugin? I'm trying to test it but I'm not having any luck getting it to link anything for me..sol
extension an exception is thrown.
Turns out my markdown was wrong, it throws an exception even with the .sol
extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ```sol ... results in highlight-source-gerber
. ```solidity ... results in highlight-source-solidity
so this should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not to fuzzy about adding those classes. The only purpose is to make linking in code snippets work. @lucaperret feel free to leave the githubClasses array empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather prefer to have it working on code snippet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to look into this a bit closer. Unfortunately I don't have capability for this today, but I'll have a look tomorrow evening.
When testing a code snippet if the import starts with
I'm not really sure why that's happening though. If you remove the If the import is |
Correct, the solidity import should start with "./" for relative path, and if not, it is a npm package. |
Looks like a regression introduced in an earlier version which seems to affect code snippets only. Code snippets are not covered by end to end tests. I tried updating all fixtures files but then the unit tests start failing. To make this PR pass I pushed just the fixture change for the code snippets. |
Thanks for your contribution @lucaperret As mentioned I’m going to look into the snippet issue and update the store version later this week. |
Hey @stefanbuck, when are you planning to release OctoLinker with this feature? |
Thanks for the reminder. I wanted to fix the highlight issue we discovered first, but I'm maxed out with other things right now. Therefore maybe best to just ship it. I'm going to tackle this at some point this week (sorry my schedule is very tight). |
If I can do anything to help you @stefanbuck feel free :) |
Hi @lucaperret, sorry for the delay I was off sick. I just created a new release which will be available very soon. Watch out for v6.10.0. Thanks again for your contribution and taking the time adding Solidity support. |
Plugin Solidity
Adds support for Solidity's
import
statement.See this solidity file as an example.
You should be able to click
"./IERC721.sol"
withinimport "./IERC721.sol";
and see that file.Demo
Todo
packages/blob-reader
fixture to add Solidity support on issues highlighted code?@octolinker/plugin-solidity
npm packageexport
statement to thepackages/core/load-plugins.js
@octolinker/plugin-solidity
topackages/core/package.json