{"id":19149971,"url":"https://github.com/smashingboxes/smashing_docs","last_synced_at":"2025-02-22T20:42:52.107Z","repository":{"id":56896231,"uuid":"51948973","full_name":"smashingboxes/smashing_docs","owner":"smashingboxes","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-03T14:57:51.000Z","size":188,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-04T04:57:03.801Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smashingboxes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-17T19:27:48.000Z","updated_at":"2022-06-10T12:30:09.000Z","dependencies_parsed_at":"2022-08-21T00:50:58.762Z","dependency_job_id":null,"html_url":"https://github.com/smashingboxes/smashing_docs","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fsmashing_docs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fsmashing_docs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fsmashing_docs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fsmashing_docs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smashingboxes","download_url":"https://codeload.github.com/smashingboxes/smashing_docs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240236196,"owners_count":19769570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:10:14.482Z","updated_at":"2025-02-22T20:42:52.077Z","avatar_url":"https://github.com/smashingboxes.png","language":"Ruby","readme":"# SmashingDocs\n\n### Based on [SmarfDoc](https://github.com/RickCarlino/smarf_doc) by [Rick Carlino](https://github.com/RickCarlino/)\n\n## Gem Installation in Rails\n\nIn your gemfile add the following to your test group:\n\n`gem 'smashing_docs', '~\u003e 1.3.5'`\n\nInstallation differs for RSpec/Minitest, so scroll to the appropriate section for guidance.\n\n## Automatic Installation (RSpec or Minitest!)\n\nAfter you bundle, run:\n\n`rails g docs:install`\n\nSmashingDocs will be configured to run on all your controller tests with the default\ntemplate.\n\nIf you're using RSpec and you haven't required `rails_helper` in your tests, do that now.\n\n`require 'rails_helper'`\n\n#### To generate your docs\n\nRun `rails g docs:build_docs`, and your docs will be waiting for you in the `smashing_docs` folder.\n\n## Manual RSpec Installation\n\nAdd this to your `rails_helper.rb` It should go outside of other blocks\n(Do not place it inside the `RSpec.configure` block).\n```ruby\nSmashingDocs.config do |c|\n  c.template_file = 'smashing_docs/template.md'\n  c.output_file   = 'smashing_docs/api_docs.md'\n  c.run_all       = true\n  c.auto_push     = false\n  c.wiki_folder   = nil\nend\n```\n\nAdd the following content to `spec_helper.rb` inside the `RSpec.configure` block\n\n`# config.after(:suite) { SmashingDocs.finish! }`\n\nIt should look like this\n```ruby\nRSpec.configure do |config|\n  # Existing code\n  config.after(:each, type: :controller) do\n    SmashingDocs.run!(request, response, true)\n  end\n  # config.after(:suite) { SmashingDocs.finish! }\nend\n```\n\n#### To run on only select tests\nSet the `c.run_all` line to `false` in `rails_helper.rb`\n```ruby\nSmashingDocs.config do |c|\n  # configs\n  c.run_all       = false\n  # configs\nend\n```\n\nThen just add `SmashingDocs.run!(request, response)` to the tests you want to run\n```ruby\nit \"responds with 200\" do\n  get :index\n  expect(response).to be_success\n  SmashingDocs.run!(request, response)\nend\n```\n\n## Manual Minitest Installation\n\nAdd the code from below to `test_helper.rb`:\n```ruby\nclass ActiveSupport::TestCase\n  # Already existing code\n  SmashingDocs.config do |c|\n    c.template_file = 'smashing_docs/template.md'\n    c.output_file   = 'smashing_docs/api_docs.md'\n    c.run_all       = true\n    c.auto_push     = false\n    c.wiki_folder   = nil\n  end\n  # More code\nend\n\nclass ActionController::TestCase \u003c ActiveSupport::TestCase\n  def teardown\n    SmashingDocs.run!(request, response, true)\n  end\nend\n\nMiniTest::Unit.after_tests { SmashingDocs.finish! }\n```\n\n#### To run on only select tests\nSet the `c.run_all` line to `false` in `test_helper.rb`\n```ruby\nSmashingDocs.config do |c|\n  # configs\n  c.run_all       = false\n  # configs\nend\n```\n\nThen just add `SmashingDocs.run!(request, response)` to specific tests\n```ruby\ndef get_index\n  get :index\n  assert response.status == 200\n  SmashingDocs.run!(request, response)\nend\n```\n\n## Setting a template\n\nIf you used the auto-installer or copied the code from above, SmashingDocs will\nlook for a template file located in `smashing_docs/template.md`\n\nThis template may be customized to fit your needs.\n\n```erb\n\u003c%= request.method %\u003e\n\u003c%= request.path %\u003e\n\u003c%= request.params %\u003e\n\u003c%= response.body %\u003e\n\u003c%= information[:note] %\u003e\n```\n\n## Where to find the docs\n\nBy default, the docs are output to `smashing_docs/api_docs.md` in the Rails project.\nYou can change this by altering the config in `test_helper.rb` (MiniTest) or\n`rails_helper.rb`(RSpec).\n\n## Additional Features\n\n#### Skipping documentation on tests\n\nTo leave certain tests out of the documentation, just add `SmashingDocs.skip` to the test.\n\n```ruby\nit \"responds with 200\" do\n  SmashingDocs.skip\n  # test code\nend\n```\n\n#### Adding information, e.g. notes\n\nSmashingDocs will log all requests and responses by default, but you can add some\n**optional** parameters as well.\n\n```ruby\nit \"responds with 200\" do\n  SmashingDocs.information(:note, \"This endpoint only responds on Tuesdays\")\n  # test code\nend\n```\nYou can store any information with `:note`, `:message`, or any other key you can think of.\nTo access information in the template, just use `\u003c%= information[:key] %\u003e`\n\n#### Auto-Push Docs to Your Project Wiki\n\nSmashingDocs can automatically push your generated docs to your project wiki.\n\n**To enable this feature**\n  1. Clone your wiki repo from Github into the same parent folder as your app\n\n  Your folder structure should be\n\n    ../projects/rails_app\n\n    ../projects/my_rails_app.wiki\n\n  2. Set the name of your wiki folder (do **not** include '.wiki')\n\n    ``` ruby\n      SmashingDocs.config do |c|\n        # configs\n        c.wiki_folder = \"my_rails_app\"\n      end\n    ```\n\n  3. Set auto_push to true in `rails_helper.rb` or `test_helper.rb`\n\n    ``` ruby\n      SmashingDocs.config do |c|\n        # configs\n        c.auto_push = true\n        # configs\n      end\n    ```\n\n  4. Build your docs with `rails g docs:build_docs`\n\n#### Generate Docs on Every Test Suite Run\n\nIf you prefer to have your docs built every time you run the test suite, and do\nnot want to run the build command, then uncomment the `SmashingDocs.finish` line\nin your `rails_helper` or `test_helper`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmashingboxes%2Fsmashing_docs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmashingboxes%2Fsmashing_docs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmashingboxes%2Fsmashing_docs/lists"}