{"id":22217465,"url":"https://github.com/restcomm/asciidoctor-code-samples","last_synced_at":"2025-03-25T07:15:47.423Z","repository":{"id":34246769,"uuid":"173698268","full_name":"RestComm/asciidoctor-code-samples","owner":"RestComm","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-30T17:16:30.000Z","size":923,"stargazers_count":0,"open_issues_count":13,"forks_count":1,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-07T01:22:34.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RestComm.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":"2019-03-04T07:49:16.000Z","updated_at":"2022-09-19T12:57:45.000Z","dependencies_parsed_at":"2023-01-15T05:38:28.925Z","dependency_job_id":null,"html_url":"https://github.com/RestComm/asciidoctor-code-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RestComm%2Fasciidoctor-code-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RestComm%2Fasciidoctor-code-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RestComm%2Fasciidoctor-code-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RestComm%2Fasciidoctor-code-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RestComm","download_url":"https://codeload.github.com/RestComm/asciidoctor-code-samples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245414544,"owners_count":20611367,"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-12-02T22:16:37.787Z","updated_at":"2025-03-25T07:15:47.401Z","avatar_url":"https://github.com/RestComm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asciidoctor-code-samples\n\n[Asciidoctor.js](https://asciidoctor.org/docs/asciidoctor.js/) extension that allows to easily add tabbed source code samples in various programming languages for API documentation written in Asciidoctor (this means it also works with [Antora](https://antora.org/)). The extension exposes a new block macro that allows usages like the following:\n\n##### 1. Asciidoctor code for HTTP GET API example:\n\n```\nsamplecode::sms[httpMethod=\"GET\",urlSuffix=\"Accounts/#(account_sid)/SMS/Messages.json\"]\n```\n\nRendered HTML:\n\n![HTTP GET Example](/doc/images/GET-example.png)\n\n##### 2. Asciidoctor code for HTTP POST API example:\n\n```\nsamplecode::sms[httpMethod=\"POST\",urlSuffix=\"Accounts/#(account_sid)/SMS/Messages.json\",bodyParameters=\"From=19876543212\u0026To=13216549878\u0026Body=Test SMS from Restcomm\u0026StatusCallback=http://status.callback.url\"]\n```\n\nRendered HTML:\n\n![HTTP POST Example](/doc/images/POST-example.png)\n\n## Quick start\n\nTODO:\n\n## Use from Antora\n\nTODO:  \n\n## How to extend the extension to handle more languages\n\nSay for example that you want to support ruby additionally. What you need to do is:\n* Create `ruby-template.txt` for GET requests and `nodejs-template-post` for POST requests in src/resources/lang-templates/\n* Add normalization logic for the new language in `asciidoctor-code-samples.js:generateSample()`, before template is 'compiled' from es6-template-strings\n* Add interpolation logic for the new language in `asciidoctor-code-samples.js:generateSample()` after template is 'compiled' so that any replacements are made before we have additional interpolation\n* Add nodejs generated HTML in asciidoctor-code-samples.js:generateSamplesDiv()\n* Add test cases to check both GET and POST conversion scenarios in `test/test/js`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frestcomm%2Fasciidoctor-code-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frestcomm%2Fasciidoctor-code-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frestcomm%2Fasciidoctor-code-samples/lists"}