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

Auto Doc #38

Merged
merged 2 commits into from Aug 14, 2018
Merged

Auto Doc #38

merged 2 commits into from Aug 14, 2018

Conversation

henrod
Copy link
Contributor

@henrod henrod commented Aug 14, 2018

docgenerator creates a doc with the following format:

{
  "handlers": {
      "metagame.playerHandler.get": {
        "input": {
          "id": "uuid.UUID" 
        },
        "output": {
          "name": "string",
          "gold": "int"
        }
      },
      ...
    }
    "remotes": {
      "metagame.playerRemote.get": {
        "input": {
          "id": "uuid.UUID" 
        },
        "output": {
          "name": "string",
          "gold": "int"
        }
      },
    },
    ...
  }
}

The game can use pitaya.Documentation() function to get this map[string]interface{} and return in any format: html in http route, a new remote, etc.

func (d docMap) toMap() map[string]interface{} {
var m map[string]interface{}
bts, _ := json.Marshal(d)
json.Unmarshal(bts, &m)

Choose a reason for hiding this comment

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

Error return value of json.Unmarshal is not checked

return name
}

return string(append([]byte{strings.ToLower(name)[0]}, name[1:len(name)]...))

Choose a reason for hiding this comment

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

should omit second index in slice, s[a:len(s)] is identical to s[a:]

@coveralls
Copy link

Pull Request Test Coverage Report for Build 390

  • 119 of 138 (86.23%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 75.369%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app.go 9 13 69.23%
service/handler.go 0 5 0.0%
docgenerator/generator.go 110 115 95.65%
service/remote.go 0 5 0.0%
Totals Coverage Status
Change from base Build 357: 0.3%
Covered Lines: 3681
Relevant Lines: 4884

💛 - Coveralls

@andrehp
Copy link
Contributor

andrehp commented Aug 14, 2018

LGTM

@cscatolini
Copy link
Contributor

Nice! I'll merge this :)

@cscatolini cscatolini merged commit 1999728 into master Aug 14, 2018
@felipejfc
Copy link
Contributor

very well done @henrod, I think this will be valuable for pitaya admin @cscatolini

@cscatolini
Copy link
Contributor

@felipejfc Yes! :) we'll integrate it as soon as we have the project up and running

@andrehp andrehp deleted the feature/auto-doc branch September 4, 2018 21:35
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.

None yet

6 participants