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

Include first 6 lines of the source code #9

Open
nikgraf opened this issue Oct 28, 2018 · 10 comments
Open

Include first 6 lines of the source code #9

nikgraf opened this issue Oct 28, 2018 · 10 comments

Comments

@nikgraf
Copy link
Owner

nikgraf commented Oct 28, 2018

No description provided.

@stereobooster
Copy link
Contributor

Separate page per hook? Then it would be possible to include whole text. For example, https://usehooks.com/useDarkMode/

@nikgraf
Copy link
Owner Author

nikgraf commented Feb 20, 2019

@stereobooster yeah, either a separate page or a section that's collapsed and can be expanded. The issue though is that some hooks might have multiple hundred lines of code. Also is it done on build time or do we fetch it on demand? An iFrame of that Github file could also do it.

@stereobooster
Copy link
Contributor

stereobooster commented Feb 21, 2019

The issue though is that some hooks might have multiple hundred lines of code.

Let's limit scope. We will care only about hooks :

  • implemented in JS as first step, in TS as second step, everything else later
  • self contained hooks e.g. we allow imports from packages, but don't allow imports from different files
  • one hook per file
  • named export, so we can identify hook by use...
  • no hooks generators, like generateUseState etc.
  • everything that doesn't fit constraints will be disqualified e.g. we will have link, but no code preview

How can we get source, and how we will keep it in sync?

...to be continued

@nikgraf
Copy link
Owner Author

nikgraf commented Feb 21, 2019

sounds good to me!

Regarding how we can get the source. In every Hook object we could link to the raw file. During build time fetch it and include the raw text. We could trigger a build every hour or two to keep it up to date.

What do you think?

@stereobooster
Copy link
Contributor

stereobooster commented Feb 22, 2019

yes good idea. I don't think we need to trigger every two hours more like once a day - once a week (but this can be configured).

Metadata and information that can be extracted

Github link - stars, forks, open issues, last updated etc
npm package name - latest published version, downloads, date of publishing
link to the raw file - source code, external dependencies, core hooks dependencies, LOC

Script to extract data

  • read hooks.json
  • convert it to stream https://highlandjs.org/
  • filter items with meta-data
  • flatmap over stream with async function (fetch)
  • log all failures, like 404 or 500
  • write output

@stereobooster
Copy link
Contributor

We have link to raw files (for some hooks) and we already fetch source to detect subhooks on each CI build, just in case anybody wants to pick up this task

@aarohmankad
Copy link

For files that have the raw source (sourceUrl), I can't seem to just fetch that url.

@dmitryrn
Copy link

dmitryrn commented Oct 3, 2019

I would like to improve something here. I already made first-6-lines-source-preview (but it seems a little bit useless). Is this relevant to make PR here?
image

@dmitryrn
Copy link

dmitryrn commented Oct 3, 2019

@stereobooster I guess I’ll pick it up

@nikgraf
Copy link
Owner Author

nikgraf commented Oct 14, 2019

@dmitryrn cool experiment. maybe rather showing the first 6 lines of code it would be good to have some insights on how many lines there are and possibly expand it to see the source?

What do you think? (keep in mind this are rough thoughts and need experimentation)

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

4 participants