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

Docs: Code Snippets Reliability #1960

Closed
arboleya opened this issue Mar 27, 2024 · 5 comments
Closed

Docs: Code Snippets Reliability #1960

arboleya opened this issue Mar 27, 2024 · 5 comments
Assignees
Labels
docs Requests pertinent to documentation

Comments

@arboleya
Copy link
Member

arboleya commented Mar 27, 2024

Here are a few examples where the code snippets behave erratically:

We should probably be considering getting rid of #context tags if possible.

All this points to the nightly version of the docs, currently at 0.77.

@arboleya arboleya added the docs Requests pertinent to documentation label Mar 27, 2024
@arboleya arboleya mentioned this issue Mar 27, 2024
@petertonysmith94
Copy link
Contributor

petertonysmith94 commented Mar 29, 2024

Summary

  • Docs-hub pulls over our raw assets (.md and .test.ts), parses, and builds them.
  • I've identified probable issues and tested their solutions (see below).
  • Maintaining two documentations systems seems obsolete to me.

Investigation

  1. Sometimes code snippets are malformatted (indentation)
    https://docs.fuel.network/docs/nightly/fuels-ts/providers/

Occurs during the fix-indent.ts process on the docs hub. Also appears to be a problem with the rust snippets.
https://docs.fuel.network/docs/nightly/fuels-rs/deploying/configurable-constants/
https://docs.fuel.network/docs/nightly/fuels-rs/predicates/send-spend-predicate/

I believe this is due to regex replacement conflicting. For all projects, languages and coding format.

  • Simplify and separate this regex replacement by project + language, should alleviate this issue and lead to more predictable results.

  1. Sometimes code snippets don't have syntax highlight

There is no syntax highlighting configured for html or html-vue in the docs hub.

  • The code snippet language changed from html-vue to html.
  • Add html to the highlighter langs in the docs-hub.

After


  1. Sometimes code snippets have "import" comments

Incorrect #import format. Should be: // #import { BN, CoinQuantityLike, ScriptTransactionRequest };

  • Additional lint checking within fuels-ts.

  1. Variables are not getting rendered

Variables not being detected. Potential solution:

  • Changing equality check to includes on the conditions.
  tsBookVersions: (node: any) => {
    return (
      typeof node.value === 'string' &&
      (node.value.includes('{{fuels}}') ||
        node.value.includes('{{fuelCore}}') ||
        node.value.includes('{{forc}}')
      )
    );
  },
  • Alter the node value directly before any other manipulation.
  visit(newTree, '', (node: any, idx, parent) => {
    if (conditions.tsBookVersions(node)) {
      node.value = node.value
        .replace('{{fuels}}', versions.FUELS)
        .replace('{{fuelCore}}', versions.FUEL_CORE)
        .replace('{{forc}}', versions.FORC);
    }
    ...
  })

  1. Button "see code in context" doesn't work on the docs portal
  • I believe this is a feature request within the docs-hub?

Side quest: We should probably be considering getting rid of #context tags if possible.

There are 54 instances of#context, 45+ should be pretty simple. Would be good to get people's ideas on the import, as I can't see a way to do it currently.
https://github.com/FuelLabs/fuels-ts/blob/master/apps/demo-typegen/src/demo.test.ts#L79

@petertonysmith94
Copy link
Contributor

Moving this back to Queued and setting to blocked as awaiting docs-hub related work.

Keeping my name on for follow up purposes 😄

@petertonysmith94 petertonysmith94 added the blocked Something is blocking development on this issue label Apr 24, 2024
@arboleya
Copy link
Member Author

Great job! Can't we close the issue as completed? 🙂

You did everything and created issues on the docs-hub repo for the remaining items.

@petertonysmith94
Copy link
Contributor

That sounds like a better idea 🥇

@petertonysmith94
Copy link
Contributor

Closing due to all issues within fuels-ts being resolved and associated docs-hub issues have been created.

@petertonysmith94 petertonysmith94 removed the blocked Something is blocking development on this issue label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Requests pertinent to documentation
Projects
None yet
Development

No branches or pull requests

2 participants