{"id":13594057,"url":"https://github.com/consolidation/comments","last_synced_at":"2025-07-26T00:13:31.614Z","repository":{"id":56957462,"uuid":"109591770","full_name":"consolidation/comments","owner":"consolidation","description":"A tool for preserving comments, e.g. when parsing YAML files.","archived":false,"fork":false,"pushed_at":"2024-12-15T10:47:06.000Z","size":35,"stargazers_count":12,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-24T00:44:39.516Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/consolidation.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-05T15:32:47.000Z","updated_at":"2024-12-15T10:47:10.000Z","dependencies_parsed_at":"2025-01-16T19:12:00.136Z","dependency_job_id":"bca25712-6767-441a-bfc7-4562471d6cca","html_url":"https://github.com/consolidation/comments","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"974fe8855b9a359f0577784e201208ca0a864882"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/consolidation/comments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consolidation%2Fcomments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consolidation%2Fcomments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consolidation%2Fcomments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consolidation%2Fcomments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/consolidation","download_url":"https://codeload.github.com/consolidation/comments/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consolidation%2Fcomments/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267091929,"owners_count":24034667,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-08-01T16:01:28.186Z","updated_at":"2025-07-26T00:13:31.562Z","avatar_url":"https://github.com/consolidation.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Consolidation\\Comments\n\nA tool for preserving comments, e.g. when parsing YAML files.\n\n[![Build Status](https://travis-ci.org/consolidation/comments.svg?branch=main)](https://travis-ci.org/consolidation/comments)\n[![Windows Build](https://ci.appveyor.com/api/projects/status/7x2amxttvvuuh7pf?svg=true)](https://ci.appveyor.com/project/greg-1-anderson/comments)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/consolidation/comments/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/consolidation/comments/?branch=main)\n[![Coverage Status](https://coveralls.io/repos/github/consolidation/comments/badge.svg?branch=main)](https://coveralls.io/github/consolidation/comments?branch=main)\n[![License](https://poser.pugx.org/consolidation/comments/license)](https://packagist.org/packages/consolidation/comments)\n\n## Component Status\n\nPrototype.\n\n## Motivation\n\nDo lightweight editing on YAML files and then rewrite the file without losing embedded comments.\n\n## Usage\n```\n// First step: read the file, parse the yaml, edit and dump the results.\n\n$original_contents = file_get_contents($filepath);\n$parsed_data = Yaml::parse($original_contents);\n$processed_data = $this-\u003emy_processing_function($parsed_data);\n$altered_contents = Yaml::dump($parsed_data, PHP_INT_MAX, 2, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);\n\n// Second step: collect comments from original document and inject them into result.\n\n$commentManager = new Comments();\n$commentManager-\u003ecollect(explode(\"\\n\", $original_contents));\n$altered_with_comments = $commentManager-\u003einject(explode(\"\\n\", $altered_contents));\n\n$result = implode(\"\\n\", $altered_with_comments);\n```\n## Limitations\n\nThe comment manager collects groups of comment lines and associates them with the first non-blank content line that follows the comment. If there are multiple non-blank content lines that are exactly the same, then the comment lines are re-injected in the same order they appeared in the original file.\n\n## Installation\n\n$ composer require consolidation/comments\n\n## Comparison to Existing Solutions\n\nSee Klausi's [yaml_comments](https://github.com/klausi/yaml_comments).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconsolidation%2Fcomments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconsolidation%2Fcomments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconsolidation%2Fcomments/lists"}