PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/_posts/archived/2011-10-28-update-nuget-docs-in-the-browser-with-github.aspx.markdown

https://gitlab.com/Blueprint-Marketing/haacked.com
Markdown | 160 lines | 122 code | 38 blank | 0 comment | 0 complexity | 040eac6f76840ef04193b88b7dc963f3 MD5 | raw file
  1. ---
  2. layout: post
  3. title: "Update NuGet Docs in the Browser with Github"
  4. date: 2011-10-28 -0800
  5. comments: true
  6. disqus_identifier: 18822
  7. categories: [nuget,open source]
  8. ---
  9. We made a recent change to make it easy to update the [NuGet
  10. documentation](http://docs.nuget.org/ "NuGet Documentation Site"). In
  11. this post, Ill cover what the change was, why we made it, and how it
  12. makes it easier to contribute to our documentation.
  13. Our docs run as a simple [ASP.NET Web
  14. Pages](http://www.asp.net/web-pages "ASP.NET Web Pages") application
  15. that renders documentation written in the
  16. [Markdown](http://daringfireball.net/projects/markdown/ "Markdown")
  17. format. The Markdown text is not stored in a database, but live as files
  18. that are part of the application source code. That allows us to use
  19. source control to version our docs.
  20. We used to host the source for the docs site in Mercurial (hg) on
  21. [CodePlex.com](http://codeplex.com/ "CodePlex"). Under the old system,
  22. it took the following to contribute docs.
  23. 1. Install Mercurial (TortoiseHG for example) if you didnt already
  24. have it.
  25. 2. Fork our repository and clone it to your local machine.
  26. 3. Open it up in Visual Studio.
  27. 4. Make and commit your changes.
  28. 5. Push your changes.
  29. 6. Send a pull request.
  30. Its no surprise that we dont get a lot of pull requests for our
  31. documentation. Oh, and I didnt even mention all the steps once we
  32. received such a pull request.
  33. As anyone whos ever run an open source product knows, its hard enough
  34. to get folks to contribute to documentation in the first place. Why add
  35. more roadblocks?
  36. To improve this situation, we moved [our documentation repository to
  37. Github](https://github.com/NuGet/NuGetDocs "NuGet Docs on Github") for
  38. three reasons:
  39. 1. In-browser editing of files with MarkDown preview.
  40. 2. Pull requests can be merged at the click of a button.
  41. 3. Support for [deploying to
  42. AppHarbor](https://github.com/blog/961-deploy-to-appharbor-from-github "Deploy to AppHarbor from Github")
  43. (which CodePlex [also
  44. has](http://blogs.msdn.com/b/codeplex/archive/2011/08/26/integration-with-appharbor.aspx "CodePlex Integration with AppHarbor"))
  45. With this in place, its now easy to be a drive-by contributor to our
  46. docs. Lets walk through an example to see what I mean. In this example,
  47. Im posing as a guy named FakeHaacked with no commit access to the
  48. NuGetDocs repository.
  49. Heres a sample page from our docs (click for larger). The words at the
  50. end of the first paragraph should be links! Doh! I should fix that.
  51. [![nuget-docs-page](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/nuget-docs-page_thumb.png "nuget-docs-page")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/nuget-docs-page_2.png)
  52. First, Ill visit the [NuGet Docs
  53. repository](https://github.com/NuGet/NuGetDocs "NuGet Docs") (TODO: Add
  54. a link to each page with the path to the Github repository page).
  55. [![nuget-docs-github](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/nuget-docs-github_thumb.png "nuget-docs-github")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/nuget-docs-github_2.png)
  56. Cool, Im logged in as **FakeHaacked**. Now I just need to navigate to
  57. the page that needs the correction. All of the documentation pages are
  58. in the **site** folder.
  59. Pro tip, type the letter t while on this page to use incremental
  60. search to search for the page you want to edit.
  61. Heres the page I want to edit.
  62. [![page-with-fork-this-button](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/page-with-fork-this-button_thumb.png "page-with-fork-this-button")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/page-with-fork-this-button_2.png)
  63. Since this file is a Markdown file, I can see a view of the file thats
  64. a nice approximation of what it will look like when its deployed. Its
  65. not exactly the same since we have different CSS styles on the
  66. production site.
  67. See that blue button just above the content and to the right? That
  68. allows me to fork this page and edit the file. Forking it, for those
  69. not familiar with distributed version control, means it will create a
  70. clone of the main repository. Im free to work and do whatever I want in
  71. that clone without worry that I will affect the real thing.
  72. Lets click that button and see what happens.
  73. [![github-markdown-editor](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/github-markdown-editor_thumb.png "github-markdown-editor")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/github-markdown-editor_2.png)
  74. Cool, I get a nice editor with preview for editing the page right here
  75. in the browser. Ill go ahead and make those last two references into
  76. Markdown formatted links.
  77. When Im done, I can scroll down, type in a commit message describing
  78. the change, and click the blue *Propose File Change* button.
  79. [![enter-commit-message](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/enter-commit-message_thumb_1.png "enter-commit-message")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/enter-commit-message_4.png)
  80. Once youre happy with the set of changes youve made, click the button
  81. to send a pull request. This lets the folks who maintain the
  82. documentation to know you have changes that are ready for them to pull
  83. in.
  84. [![send-a-pull-request](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/send-a-pull-request_thumb.png "send-a-pull-request")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/send-a-pull-request_2.png)
  85. And thats it. Youve done your part. Thank you for your contribution to
  86. our docs! Now lets look at what happens on the other side. Ill put on
  87. my project maintainer hat and visit the site. Notice Im logged in as
  88. **Haacked** now and I see theres an outstanding pull
  89. request.[![pull-requests-nuget-docs](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/pull-requests-nuget-docs_thumb.png "pull-requests-nuget-docs")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/pull-requests-nuget-docs_2.png)
  90. Cool, I can take a look at it, quickly see a diff, and comment on it.
  91. Notice that Github was able to determine that this file is safe to
  92. automatically merge into the master branch.
  93. [![merge-pull-request](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/merge-pull-request_thumb_1.png "merge-pull-request")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/merge-pull-request_4.png)
  94. All I have to do is click the big blue button, enter a message, and Im
  95. done!
  96. [![confirm-merge](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/confirm-merge_thumb.png "confirm-merge")](http://haacked.com/images/haacked_com/Windows-Live-Writer/Update-NuGet-Docs-in-the-Browser-with-Gi_D96F/confirm-merge_2.png)
  97. Its that easy for me to merge in your changes.
  98. Summary
  99. -------
  100. You might ask why we dont use the [Github
  101. Pages](http://pages.github.com/ "Github Pages") feature (or even
  102. [Git-backed
  103. wikis](https://github.com/blog/699-making-github-more-open-git-backed-wikis "Git-backed wikis")).
  104. We started the docs site before we were on Github and didnt know about
  105. the pages feature.
  106. If I were to start over, Id probably just use that. Maybe well migrate
  107. in the future. One benefit of our current implementation is we get that
  108. nice Table of Contents widget generated for us dynamically (which we can
  109. probably do with [Github Pages and
  110. Jekyll](https://github.com/mojombo/jekyll "Jekyll")) and we can use
  111. Razor for our layout template.
  112. The downside of our current approach is that we cant create new doc
  113. pages this way, but Ill submit a feature request to the Github team and
  114. see what happens.
  115. So if you are reading the NuGet docs, and see something that makes you
  116. think, That aint right!, please go fix it! Its easy and contributing
  117. to open source documentation makes you a good person. Its how I got
  118. started in open source.
  119. Oh, and if you happen to be experienced with Git, you can always use the
  120. traditional method of cloning the repository to your local machine and
  121. making changes. That gives you the benefit of running the site to look
  122. at your change.