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

2922 michel codec doc #2972

Merged
merged 38 commits into from
May 28, 2024
Merged

2922 michel codec doc #2972

merged 38 commits into from
May 28, 2024

Conversation

hui-an-yang
Copy link
Collaborator

@hui-an-yang hui-an-yang commented May 24, 2024

adding michel codec documentation page to website
closes #2922

Thank you for your contribution to Taquito.

Before submitting this PR, please make sure:

  • Your code builds cleanly without any errors or warnings
  • You have run the linter against the changes
  • You have added unit tests (if relevant/appropriate)
  • You have added integration tests (if relevant/appropriate)
  • All public methods or types have TypeDoc coverage with a complete description, and ideally an @example
  • You have added or updated corresponding documentation
  • If relevant, you have written a first draft summary describing the change for inclusion in Release Notes.

In this PR, please also make sure:

  • You have linked this PR to the issue by putting closes #TICKETNUMBER in the description box (when applicable)
  • You have added a concise description on your changes

Release Note Draft Snippet

If relevant, please write a summary of your change that will be suitable for
inclusion in the Release Notes for the next Taquito release.

Copy link

github-actions bot commented May 24, 2024

A new deploy preview is available on Cloudflare Pages at https://ada46418.taquito-test-dapp.pages.dev

Copy link

github-actions bot commented May 24, 2024

New packages have been deployed to the preview repository at https://npm.preview.tezostaquito.io/.

Published packages:

npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/
npm i @taquito/[email protected] --registry https://npm.preview.tezostaquito.io/

@hui-an-yang hui-an-yang linked an issue May 27, 2024 that may be closed by this pull request
2 tasks
@hui-an-yang hui-an-yang requested review from ac10n and dsawali May 27, 2024 17:08
@hui-an-yang hui-an-yang marked this pull request as ready for review May 27, 2024 17:08
const p = new Parser(parserOptions);
```

### parseJSON & emitMicheline - Parse JSON Michelson and convert it to Micheline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant title, remove 'parseJSON & emitMicheline`

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are in place so the outline of the doc display the function names

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you listed them right below it, I would remove it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heading titles for documentation should be concise and clear

Copy link
Contributor

@dsawali dsawali May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also having the title of methods as a preface to what it does is not a very good habit when writing technical documentation (it does work in some exceptions, but not in this case)

When writing a heading for a section, you want to explain what this section describes:

Parsing JSON Michelson and converting to Micheline

and then you would describe what methods to use in the content of said section

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did some reading on writing technical docs outlines and it says it's good idea to have both method name with concise description and I also reference ethereum taquito equivalent tool docs, their outline have method name only. I think this is a preference and i decided to keep them.

.catch((error) => println(`Error: ${JSON.stringify(error, null, 2)}`));
```

### parseMichelineExpression - Parse Micheline and convert it to JSON Michelson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, remove 'parseMichelineExpression - '


## PACK and UNPACK locally

### packData & packDataBytes - Pack Michelson data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

// { bytes: "050a0000001901be41ee922ddd2cf33201e49d32da0afec571dce300666f6f" }
```

### unpackData & unpackDataBytes - Unpack Michelson data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


### packData & packDataBytes - Pack Michelson data
`packData` & `packDataBytes` serialize any value of packable type to its optimized binary representation identical to the one used by PACK Michelson instructions.
Without a type definition (not recommended) the data will be encoded as a binary form of a generic Michelson expression.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma after '(not recommended)'.

```

### unpackData & unpackDataBytes - Unpack Michelson data
Deserialize a byte array into the corresponding Michelson value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*Deserializes a byte array into *its corresponding Michelson value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grammarly compliants Deserializes but i've updated *its corresponding Michelson value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is grammatically correct in this context since it's referring to a previous statement

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is akin to saying 'This method deserializes...'

you wouldn't say 'This method deserialize..'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deserialize should work too, but just pointing out that testing that sentence in grammarly will obviously output an error due to the false premise

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete sentence will be "unpackData & unpackDataBytes deserialize..."


### unpackData & unpackDataBytes - Unpack Michelson data
Deserialize a byte array into the corresponding Michelson value.
Without a type definition (not recommended) the binary data will be treated as a binary form of a generic Michelson expression and returned as is.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing comma after parentheses

author: Hui-An Yang
---

The purpose of the `taquito/michel-codec` package is to convert and validate Michelson expressions between JSON-based Michelson and Micheline. This package also comes with functions like `packData`, `packDataBytes`, `unpackData` and `unpackDataBytes` to serialize any value of packable type to its optimized binary representation locally and vice versa, like Michelson instructions `PACK` and `UNPACK`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend writing in an active tense. for example:

The `taquito/michel-codec` package converts and validates Michelson expressions between JSON-based Michelson and Micheline. It comes with various functions like.....

The purpose of the `taquito/michel-codec` package is to convert and validate Michelson expressions between JSON-based Michelson and Micheline. This package also comes with functions like `packData`, `packDataBytes`, `unpackData` and `unpackDataBytes` to serialize any value of packable type to its optimized binary representation locally and vice versa, like Michelson instructions `PACK` and `UNPACK`.

## Parser class
To use the parser class as is, we import it from the package and initialize it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*To use the parser class, import it as follows

  • not necessary to say as is, you expanded the parameters below.
  • we also add a very clear example right below it, so just point to the example instead of mentioning it in text

const p = new Parser()
```
### Configuration
If you'd like to customize the parser class to `expandMacros` or `expandGlobalConstant,` you can configure its `ParserOptions` through initialization.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend saying something like, 'You can pass parameters to the parser class to blablabla' instead of 'customizing' the parser class. Customizing implies something like the taquito-http-util customization. This is just extra params.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate the difference of extra params and customize?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customize would be to modify the method, refer to this doc https://taquito.io/docs/next/cancel_http_requests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update to this "You can configure the parser class by passing ParserOptions through initialization with expandMacros and expandGlobalConstant properties."

Copy link

cloudflare-workers-and-pages bot commented May 27, 2024

Deploying taquito with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6010777
Status: ✅  Deploy successful!
Preview URL: https://3096d0bc.taquito.pages.dev
Branch Preview URL: https://2922-michel-codec-doc.taquito.pages.dev

View logs

Copy link
Contributor

@dsawali dsawali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments not yet addressed

@hui-an-yang hui-an-yang requested a review from dsawali May 28, 2024 17:10
@hui-an-yang hui-an-yang merged commit 19adca7 into master May 28, 2024
9 of 10 checks passed
@hui-an-yang hui-an-yang deleted the 2922-michel-codec-doc branch May 28, 2024 21:43
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

Successfully merging this pull request may close these issues.

Add Michel-codec package documentation on website
2 participants