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

Trim whitespace from metadata field docs #920

Closed
cmichi opened this issue Sep 14, 2021 · 4 comments
Closed

Trim whitespace from metadata field docs #920

cmichi opened this issue Sep 14, 2021 · 4 comments
Labels
A-ink_metadata [ink_metadata] Work item E-help wanted Extra attention is needed good first issue Good for newcomers

Comments

@cmichi
Copy link
Collaborator

cmichi commented Sep 14, 2021

I thought we fixed this a long time ago, but apparently the field docs in our metadata still contains whitespaces at the beginning:

$ cd examples/flipper/
$ cargo +nightly contract build
$ cat /target/ink/flipper.contract  | jq .spec.messages[].docs
[
  " Flips the current value of the Flipper's boolean."
]
[
  " Returns the current value of the Flipper's boolean."
]
@cmichi cmichi added E-help wanted Extra attention is needed good first issue Good for newcomers A-ink_metadata [ink_metadata] Work item labels Sep 14, 2021
@cmichi cmichi changed the title Trim whitespace from metadata docs Trim whitespace from metadata field docs Sep 14, 2021
@Robbepop
Copy link
Collaborator

I am not sure if this is entirely bad since this is an artifact of the actual Rust code itself.
For example:

/// Foo.
fn foo() {}

Will produce " Foo." as captured documentation string whereas ...

///Foo.
fn foo() {}

Will produce `"Foo.".

Also if we treat the output as Markdown we should be careful with removal of whitespace since Markdown has semantic whitespace. E.g. indentation of a block is a code block.

@cmichi
Copy link
Collaborator Author

cmichi commented Sep 17, 2021

I am not sure if this is entirely bad since this is an artifact of the actual Rust code itself.

Yeah sure, but I think we shouldn't require people to write comments as ///Foo. just to get rid of whitespaces.

Also if we treat the output as Markdown we should be careful with removal of whitespace since Markdown has semantic whitespace. E.g. indentation of a block is a code block.

I agree. I think a valid condition would be to only remove the whitespace if every item in the docs Array starts with a whitespace.

@Robbepop
Copy link
Collaborator

I agree. I think a valid condition would be to only remove the whitespace if every item in the docs Array starts with a whitespace.

Yes but just remove the general whitespace indentation because this is valid markdown, too:

The following lines are showing text as code:

    fn main() {
        "Hello, World!"
    }

However, if we see somthing like this:

 Every line stars with a single whitespace.
 So we can actually remove this single whitespace probably without interfering
 with the semantics of the whitespace below.
 
 The following lines are showing text as code:

    fn main() {
        "Hello, World!"
    }

@SkymanOne
Copy link
Contributor

Fixed by #1385

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ink_metadata [ink_metadata] Work item E-help wanted Extra attention is needed good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants