{"id":20057619,"url":"https://github.com/todesking/typedocs","last_synced_at":"2026-03-06T04:37:03.899Z","repository":{"id":4683315,"uuid":"5829941","full_name":"todesking/typedocs","owner":"todesking","description":"Human/Machine readable method type annotations for Ruby","archived":false,"fork":false,"pushed_at":"2014-05-18T16:06:45.000Z","size":436,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-17T16:50:14.737Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/todesking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-16T14:26:57.000Z","updated_at":"2019-03-20T19:03:49.000Z","dependencies_parsed_at":"2022-08-30T18:01:59.807Z","dependency_job_id":null,"html_url":"https://github.com/todesking/typedocs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/todesking/typedocs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ftypedocs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ftypedocs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ftypedocs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ftypedocs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/todesking","download_url":"https://codeload.github.com/todesking/typedocs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/todesking%2Ftypedocs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30161915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T04:22:03.816Z","status":"ssl_error","status_checked_at":"2026-03-06T04:22:00.183Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-13T12:59:40.844Z","updated_at":"2026-03-06T04:37:03.861Z","avatar_url":"https://github.com/todesking.png","language":"Ruby","funding_links":[],"categories":["Ruby Type Annotations / Signatures"],"sub_categories":[],"readme":"# Typedocs : Human/Machine readable method specifications\n\n[![Build Status](https://travis-ci.org/todesking/typedocs.png)](https://travis-ci.org/todesking/typedocs)\n\nThe goal of the project is to provide user-friendly type annotations for Ruby.\n\nNOTICE: This gem is very beta, any APIs/syntaxes may change in future.\n\n## Platform\n\nRuby 1.9/2.0\n\n## Usage\n\n### Method type annotations with dynamic type checking\n\n```ruby\nrequire 'typedocs/enable' # Enable dynamic type-checking\n\nrequire 'typedocs'\nclass X\n  include Typedocs::DSL\n\n  tdoc \"Numeric -\u003e Numeric\"\n  def square x\n    x * x\n  end\nend\n\nX.new.square 10\n# =\u003e 100\n\nX.new.square '100'\n# Typedocs::TypeMissmatch: Argument x is not Numeric('100')\n```\n\nBy default, `require 'typedocs'` define some do-nothing methods.\nFor dynamic type-checking, `require 'typedocs/enable'` bereore `require 'typedocs'`.\nFor example: `ruby -rtypedocs/enable ./foo.rb`, or require it in `spec_helper.rb`, etc.\n\n### Example\n```ruby\nclass Example\n  include Typedocs::DSL\n\n  tdoc \"String\"\n  def to_s; end\n\n  tdoc \"Integer -\u003e String|nil\"\n  def [](index); end\n\n  tdoc \"\u0026 -\u003e Array || Enumerable\"\n  def map; end\n\n  tdoc \"[[key:Integer, value:String]...]\"\n  def to_a; end\n\n  tdoc \"title:String -\u003e url:String|Hash -\u003e ?options:Hash -\u003e String ||\n        url:String|Hash -\u003e ?options:Hash -\u003e \u0026content -\u003e String\"\n  def link_to(*args); end\nend\n```\n\n### User Defined Types\n\n```ruby\nclass SomethingBuilder\n  include Typedocs\n  tdoc.typedef \"@ConfigHash\", \"{:attr_1 =\u003e Integer, :attr_2 =\u003e String}\"\n\n  tdoc \"@ConfigHash -\u003e Something\"\n  def build(config); end\n\n  tdoc \"@ConfigHash -\u003e SomeContext -\u003e Something\"\n  def build_with_context(config, context); end\nend\n```\n\n### Features\n\n```\nsyntax: arg1_name:Type1 -\u003e arg2_name:Type2 -\u003e \u0026block -\u003e ResultType\n\n# Type name\nTypeName\n\n# User defined type name\n@TypeName\n\n# Exact value(symbol, string)\n:a\n'a'\n\"a\"\n\n# Special matchers\n_     # Any object\nvoid  # The value is not used. Typically for return type.\n      # If return type is omitted, treated as void.\n\n# Data structure\n[Type...]   # Array of Type\n[T1, T2]    # Fixed number array(tuple)\n{K =\u003e V}    # Hash specified by key type and value type\n{:key1 =\u003e V1, \"key2\" =\u003e V2}\n            # Hash specified by possible key value and value type\n{:key1 =\u003e V1, \"Key2\" =\u003e V2, ...}\n            # Same as above, but may contains unspecified key-value pair\n\n# Selection\nA|B  # A or B\n\n# Qualifier\n*var_arg\n?optional_arg\n\n\u0026block\n?\u0026optional_block\n```\n\n### Grammer\n\nUse `typedocs grammer` command for generate list of grammer.\n\n```\n         METHOD_SPEC \u003c- SPACES (METHOD_SPEC1 ('||' SPACES METHOD_SPEC1){0, })\n              SPACES \u003c- \\\\s{0, }\n        METHOD_SPEC1 \u003c- ((ARG_SPEC '-\u003e' SPACES){0, }) ((BLOCK_SPEC '-\u003e' SPACES)?) (RETURN_SPEC?)\n            ARG_SPEC \u003c- (ARG_ATTR?) NAMED_TYPE\n            ARG_ATTR \u003c- [*?]\n          NAMED_TYPE \u003c- TYPE / ARG_NAME ((':' SPACES TYPE)?)\n                TYPE \u003c- TYPE1 ('|' SPACES !('|' SPACES) TYPE1){0, }\n               TYPE1 \u003c- TYPE_NAME / DEFINED_TYPE_NAME / ANY / VOID / ARRAY / TUPLE / HASHES / VALUES\n           TYPE_NAME \u003c- '::'? ([A-Z] [A-Za-z0-9_]{0, } ('::' [A-Z] [A-Za-z0-9_]{0, }){0, }) SPACES\n   DEFINED_TYPE_NAME \u003c- '@' TYPE_NAME\n                 ANY \u003c- '_' SPACES\n                VOID \u003c- 'void' SPACES / '--' SPACES\n               ARRAY \u003c- '[' SPACES NAMED_TYPE '...' SPACES ']' SPACES\n               TUPLE \u003c- '[' SPACES ((NAMED_TYPE (',' SPACES NAMED_TYPE){0, }){0, }) ']' SPACES\n              HASHES \u003c- HASH_V / HASH_T\n              HASH_V \u003c- '{' SPACES (HASH_V_ENTRY (',' SPACES HASH_V_ENTRY){0, }) ((',' SPACES '...' SPACES)?) '}' SPACES\n        HASH_V_ENTRY \u003c- VALUES '=\u003e' SPACES NAMED_TYPE\n              VALUES \u003c- NIL_VALUE / STRING_VALUE / SYMBOL_VALUE\n           NIL_VALUE \u003c- 'nil' SPACES\n        STRING_VALUE \u003c- STRING_VALUE_SQ / STRING_VALUE_DQ\n     STRING_VALUE_SQ \u003c- ''' SPACES (([^'] / '\\''){0, }) ''' SPACES\n     STRING_VALUE_DQ \u003c- '\"' SPACES (([^\\\"] / '\\\"'){0, }) '\"' SPACES\n        SYMBOL_VALUE \u003c- ':' ([A-Za-z_] [A-Za-z0-9_]{0, } [?!]?) SPACES\n              HASH_T \u003c- '{' SPACES NAMED_TYPE '=\u003e' SPACES NAMED_TYPE '}' SPACES\n            ARG_NAME \u003c- ([_a-z0-9?!]{1, }) SPACES\n          BLOCK_SPEC \u003c- (('?' SPACES)?) '\u0026' SPACES (ARG_NAME?)\n         RETURN_SPEC \u003c- NAMED_TYPE\n```\n\n### Fallbacks\n\n```\n# in your gem dir\n$ typedocs install-fallback lib\n```\n\nand\n\n```ruby\nrequire 'typedocs/fallback' # instead of `require 'typedocs'`\n\nclass A\n  include Typedocs::DSL\n  # ...\nend\n```\n\nWith that, your library works without typedocs dependency.\nWhen typedocs gem not found, `tdoc` method do nothing.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'typedocs'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install typedocs\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## TODO\n\n    BUG\n      typedef @A = X|Y ; typedef @B = [@A ...] ; and use @B cause error\n      tdoc '*Symbol -\u003e ?{Symbol =\u003e Object} -\u003e _' cause error on arg check phase.\n    YARD style comment notation\n      # @tdoc A -\u003e B\n      Support YARD standard tag(@param, @return) (Need another parser...)\n    Type spec:\n      Block type specification\n      Preset UDTs\n        @Boolean\n      UDT with dynamic rule\n        typedef(:@Positive) {|v| v \u003e 0 }\n      Duck typing\n      More named type: result:String|not_found:nil\n    Method spec:\n      Exception\n        String -\u003e Integer !KeyNotFound|IOError\n    Skip checking for specific argument\n      foo 1,2,skip_validation('3')\n    Informative error message\n    Enable/Disable for specific class\n    get typedoc from method\n    Self hosting\n    Re-define existing method's spec\n    Auto spec inference(from argument name)\n    define from outer\n    Support attr_accessor\n\n## Changes\n\n### 0.0.1\n* Initial release\n\n\n* * * * *\n\n\n    vim: set shiftwidth=2 expandtab:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftodesking%2Ftypedocs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftodesking%2Ftypedocs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftodesking%2Ftypedocs/lists"}