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

doc: fix markdown for the decimal package #202

Merged
merged 1 commit into from
Aug 17, 2022

Conversation

oleg-jukovec
Copy link
Collaborator

@oleg-jukovec oleg-jukovec commented Aug 4, 2022

The patch hides the implementation details of the Decimal type from
documentation. It provides comments for Decimal.MarshalMsgpack and
Decimal.UnmarshalMsgpack.

How-to test:

  1. Run: $ godoc -http=:8080 in the go-tarantool folder.
  2. Open http://localhost:8080/pkg/github.com/tarantool/go-tarantool/decimal/ .

I didn't forget about (remove if it is not applicable):

Related issues:

Closes #201

@oleg-jukovec oleg-jukovec marked this pull request as ready for review August 4, 2022 12:55
Comment on lines 3 to 39
// The package implements methods to encode and decode BCD.
//
// BCD (Binary-Coded Decimal) is a sequence of bytes representing decimal
// digits of the encoded number (each byte has two decimal digits each encoded
// using 4-bit nibbles), so byte >> 4 is the first digit and byte & 0x0f is the
// second digit. The leftmost digit in the array is the most significant. The
// rightmost digit in the array is the least significant.
//
// The first byte of the BCD array contains the first digit of the number,
// represented as follows:
//
// | 4 bits | 4 bits |
// = 0x = the 1st digit
//
// (The first nibble contains 0 if the decimal number has an even number of
// digits). The last byte of the BCD array contains the last digit of the
// number and the final nibble, represented as follows:
//
// | 4 bits | 4 bits |
// = the last digit = nibble
//
// The final nibble represents the number's sign: 0x0a, 0x0c, 0x0e, 0x0f stand
// for plus, 0x0b and 0x0d stand for minus.
//
// Examples:
//
// The decimal -12.34 will be encoded as 0xd6, 0x01, 0x02, 0x01, 0x23, 0x4d:
//
// | MP_EXT (fixext 4) | MP_DECIMAL | scale | 1 | 2,3 | 4 (minus) |
// | 0xd6 | 0x01 | 0x02 | 0x01 | 0x23 | 0x4d |
//
// The decimal 0.000000000000000000000000000000000010 will be encoded as
// 0xc7, 0x03, 0x01, 0x24, 0x01, 0x0c:
//
// | MP_EXT (ext 8) | length | MP_DECIMAL | scale | 1 | 0 (plus) |
// | 0xc7 | 0x03 | 0x01 | 0x24 | 0x01 | 0x0c |
//
Copy link
Member

Choose a reason for hiding this comment

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

This comment about BCD encoding/decoding was placed to a file bcd.go intentionally.
Sure, you can move it to another place, although I don't get your motivation.

Additionally, this change is not related to the fixed ticket, why it was added to commit with fix?

Copy link
Collaborator Author

@oleg-jukovec oleg-jukovec Aug 4, 2022

Choose a reason for hiding this comment

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

The change related to the second part of the commit: "It also makes the package description less confusing, removes duplication."

It fixes general description of the decimal subpackage:
godoc

I can split the commit into two parts, but that looks redundant to me.

Copy link
Collaborator Author

@oleg-jukovec oleg-jukovec Aug 4, 2022

Choose a reason for hiding this comment

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

Perhaps the description of the internal implementation is redundant in the description of the package. I'm hesitant to turn it into a code comment.

@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-201-fix-decimal-godoc branch from 520bb71 to e9f45ab Compare August 8, 2022 11:24
@oleg-jukovec
Copy link
Collaborator Author

oleg-jukovec commented Aug 8, 2022

I've moved the implementation details from GoDoc comments to the code comments.

@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-201-fix-decimal-godoc branch 2 times, most recently from ff497a2 to ba1aa4b Compare August 11, 2022 13:03
@oleg-jukovec oleg-jukovec requested review from DifferentialOrange and removed request for AnaNek August 17, 2022 09:12
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-201-fix-decimal-godoc branch 2 times, most recently from 1283d64 to a820c8d Compare August 17, 2022 10:18
@oleg-jukovec oleg-jukovec changed the title decimal: fix godoc doc: fix markdown for decimal package Aug 17, 2022
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-201-fix-decimal-godoc branch from a820c8d to 89896c3 Compare August 17, 2022 10:42
@oleg-jukovec oleg-jukovec changed the title doc: fix markdown for decimal package doc: fix markdown for the decimal package Aug 17, 2022
@oleg-jukovec oleg-jukovec mentioned this pull request Aug 17, 2022
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-201-fix-decimal-godoc branch from 89896c3 to 9ee249f Compare August 17, 2022 11:01
The patch hides the implementation details of the Decimal type from
documentation. It provides comments for Decimal.MarshalMsgpack and
Decimal.UnmarshalMsgpack.

Closes #201
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-201-fix-decimal-godoc branch from 9ee249f to b9ddb95 Compare August 17, 2022 11:10
@oleg-jukovec oleg-jukovec merged commit e948683 into master Aug 17, 2022
@oleg-jukovec oleg-jukovec deleted the oleg-jukovec/gh-201-fix-decimal-godoc branch August 17, 2022 11:23
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.

Broken GoDoc in comment for Decimal.UnmarshalMsgpack
3 participants