{"action":"created","comment":{"url":"https://api.github.com/repos/bem/bem-method/pulls/comments/44132596","id":44132596,"diff_hunk":"@@ -0,0 +1,125 @@\n+# Декларации в БЭМ\n+\n+Чтобы собрать только необходимые БЭМ-сущности для постороения страницы (читай «частного случая [бандла](../build-method/build-method.ru.md#bundle)»), можно воспользоваться **декларацией**.\n+\n+Декларация представляет собой список [блоков](../definitions/definitions.ru.md#Блок), [элементов](../definitions/definitions.ru.md#Элемент) и [модификаторов](../definitions/definitions.ru.md#Модификатор), которые используются на странице. Таким образом, декларация ограничивает количество сущностей, попадающих в сборку. Нет необходимости подключать все блоки проекта, если можно собрать только нужные по списку.\n+\n+Существуют различные [способы построения декларации](#Способы-получения-декларации).\n+\n+Задача декларации определить, что и в каком порядке подключать в сборку.\n+\n+>В БЭМ-платформе описание страницы создается в формате BEMJSON, а декларация страницы описывается в формате BEMDECL, например:\n+```js\n+exports.blocks = [\n+    { name: 'input' },\n+    { name: 'button' },\n+    { name: 'checkbox' }\n+];\n+```\n+\n+## Способы получения декларации\n+\n+Декларация может формироваться вручную (для этого нужно перечислить БЭМ-сущности, необходимые для построения страницы) или строиться автоматически:\n+\n+* [по описанию страницы](#Создание-декларации-по-описанию-страницы)\n+* [с помощью интроспекции файловой системы](#Создание-декларации-с-помощью-интроспекции-файловой-системы)\n+\n+### Создание декларации по описанию страницы\n+\n+В БЭМ-проекте структура страницы описывается с помощью [БЭМ-дерева](../definitions/definitions.ru.md#БЭМ-дерево). HTML страницы содержит классы с именами всех используемых блоков, элементов и модификаторов. БЭМ-дерево может быть построено автоматически по классам из HTML-файла или создано вручную.\n+\n+При сборке страницы декларация формируется автоматически на основании данных из БЭМ-дерева: все сущности (блоки, элементы и модификаторы) попадают в декларацию в требуемом порядке, без повторений и отображения вложенности. Результатом сборки являются, например, CSS- и JavaScript-файлы для этой страницы.\n+\n+>Один из инструментов, позволяющих получить БЭМ-дерево по HTML-структуре страницы — [html2bemjson](https://github.com/bem-incubator/html2bemjson).\n+\n+![Способ создания декларации](https://img-fotki.yandex.ru/get/6114/246231603.1/0_162b0c_f5211dc6_orig)\n+\n+>Пример проекта, в котором формируется отдельная декларация для каждой страницы — [Создаем свой проект на БЭМ](https://ru.bem.info/tutorials/start-with-project-stub/).\n+\n+### Создание декларации с помощью интроспекции файловой системы\n+\n+При сборке в декларацию автоматически попадают все БЭМ-сущности, находящиеся в файловой системе проекта со всех уровней переопределения.\n+\n+![Способ создания декларации](https://img-fotki.yandex.ru/get/4510/246231603.1/0_162b0d_d4139277_orig)\n+\n+>В [bem-components](https://ru.bem.info/libs/bem-components/) такой способ создания декларации используется для поставки библиотеки в виде [Dist](https://ru.bem.info/libs/bem-components/current/#Варианты-поставки-библиотеки).\n+\n+## Способы управления декларациями\n+\n+С помощью деклараций можно управлять набором сущностей, попадающих в сборку. Декларации можно совмещать, повторно использовать, выделять общие части или различия. Такое управление дает возможность собирать все страницы в один [бандл](../build-method/build-method.ru.md#bundle), догружать необходимые части страницы по требованию, повторно использовать уже собранные общие компоненты на разных страницах и не только.\n+\n+Возможные действия с декларациями:\n+\n+* [сложение](#Объединение-нескольких-деклараций-в-одну) — объединение нескольких деклараций в одну;\n+* [вычитание](#Получение-разницы-между-декларациями) — получение разницы между декларациями;\n+* [пересечение](#Получение-декларации-на-основе-пересечения-нескольких-других) — получение декларации для общей части нескольких деклараций.\n+\n+### Объединение нескольких деклараций в одну\n+\n+Применяется для создания общих файлов технологий (например, общего CSS- и JavaScript-файла) для нескольких страниц. Используется, если необходимо загрузить все страницы одновременно и не тратить время при переходе между ними.\n+\n+```\n+Декларация 1            Декларация 2            Декларация 3\n+\n+[                       [                       [\n+    'header',               'header',               'header',\n+    'input',                'input',                'input',\n+    'button',               'button',               'button',\n+    'link',                                         'link',\n+    'attach',     +                        +        'attach',\n+                            'menu',                 'menu',\n+                            'image',                'image',\n+    'checkbox',                                     'checkbox',\n+                            'popup'                 'popup',\n+    'textarea'                                      'textarea'\n+]                       ]                       ]\n+```\n+\n+![Объединение деклараций](https://img-fotki.yandex.ru/get/15553/246231603.1/0_17be5e_b27a0dcd_orig.png)","path":"method/declaration/declaration.ru.md","position":78,"original_position":78,"commit_id":"878e3822c5df8688910ab0311d7ebcf54601bfc5","original_commit_id":"878e3822c5df8688910ab0311d7ebcf54601bfc5","user":{"login":"maslinych","id":784009,"avatar_url":"https://avatars.githubusercontent.com/u/784009?v=3","gravatar_id":"","url":"https://api.github.com/users/maslinych","html_url":"https://github.com/maslinych","followers_url":"https://api.github.com/users/maslinych/followers","following_url":"https://api.github.com/users/maslinych/following{/other_user}","gists_url":"https://api.github.com/users/maslinych/gists{/gist_id}","starred_url":"https://api.github.com/users/maslinych/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maslinych/subscriptions","organizations_url":"https://api.github.com/users/maslinych/orgs","repos_url":"https://api.github.com/users/maslinych/repos","events_url":"https://api.github.com/users/maslinych/events{/privacy}","received_events_url":"https://api.github.com/users/maslinych/received_events","type":"User","site_admin":false},"body":"А пример юзкейса? (как в разделе про вычитание деклараций, чем сложение хуже?)","created_at":"2015-11-06T12:45:11Z","updated_at":"2015-11-06T12:45:11Z","html_url":"https://github.com/bem/bem-method/pull/338#discussion_r44132596","pull_request_url":"https://api.github.com/repos/bem/bem-method/pulls/338","_links":{"self":{"href":"https://api.github.com/repos/bem/bem-method/pulls/comments/44132596"},"html":{"href":"https://github.com/bem/bem-method/pull/338#discussion_r44132596"},"pull_request":{"href":"https://api.github.com/repos/bem/bem-method/pulls/338"}}},"pull_request":{"url":"https://api.github.com/repos/bem/bem-method/pulls/338","id":48747298,"html_url":"https://github.com/bem/bem-method/pull/338","diff_url":"https://github.com/bem/bem-method/pull/338.diff","patch_url":"https://github.com/bem/bem-method/pull/338.patch","issue_url":"https://api.github.com/repos/bem/bem-method/issues/338","number":338,"state":"closed","locked":false,"title":"Documentation: bem build update","user":{"login":"innabelaya","id":6286656,"avatar_url":"https://avatars.githubusercontent.com/u/6286656?v=3","gravatar_id":"","url":"https://api.github.com/users/innabelaya","html_url":"https://github.com/innabelaya","followers_url":"https://api.github.com/users/innabelaya/followers","following_url":"https://api.github.com/users/innabelaya/following{/other_user}","gists_url":"https://api.github.com/users/innabelaya/gists{/gist_id}","starred_url":"https://api.github.com/users/innabelaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/innabelaya/subscriptions","organizations_url":"https://api.github.com/users/innabelaya/orgs","repos_url":"https://api.github.com/users/innabelaya/repos","events_url":"https://api.github.com/users/innabelaya/events{/privacy}","received_events_url":"https://api.github.com/users/innabelaya/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-26T14:39:20Z","updated_at":"2015-11-06T12:45:11Z","closed_at":"2015-10-29T11:20:43Z","merged_at":"2015-10-29T11:20:43Z","merge_commit_sha":"023b9c8e9c276923e8685cb646fc3cb2ad01e157","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bem/bem-method/pulls/338/commits","review_comments_url":"https://api.github.com/repos/bem/bem-method/pulls/338/comments","review_comment_url":"https://api.github.com/repos/bem/bem-method/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bem/bem-method/issues/338/comments","statuses_url":"https://api.github.com/repos/bem/bem-method/statuses/878e3822c5df8688910ab0311d7ebcf54601bfc5","head":{"label":"bem:bem-build-update","ref":"bem-build-update","sha":"878e3822c5df8688910ab0311d7ebcf54601bfc5","user":{"login":"bem","id":223412,"avatar_url":"https://avatars.githubusercontent.com/u/223412?v=3","gravatar_id":"","url":"https://api.github.com/users/bem","html_url":"https://github.com/bem","followers_url":"https://api.github.com/users/bem/followers","following_url":"https://api.github.com/users/bem/following{/other_user}","gists_url":"https://api.github.com/users/bem/gists{/gist_id}","starred_url":"https://api.github.com/users/bem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bem/subscriptions","organizations_url":"https://api.github.com/users/bem/orgs","repos_url":"https://api.github.com/users/bem/repos","events_url":"https://api.github.com/users/bem/events{/privacy}","received_events_url":"https://api.github.com/users/bem/received_events","type":"Organization","site_admin":false},"repo":{"id":820900,"name":"bem-method","full_name":"bem/bem-method","owner":{"login":"bem","id":223412,"avatar_url":"https://avatars.githubusercontent.com/u/223412?v=3","gravatar_id":"","url":"https://api.github.com/users/bem","html_url":"https://github.com/bem","followers_url":"https://api.github.com/users/bem/followers","following_url":"https://api.github.com/users/bem/following{/other_user}","gists_url":"https://api.github.com/users/bem/gists{/gist_id}","starred_url":"https://api.github.com/users/bem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bem/subscriptions","organizations_url":"https://api.github.com/users/bem/orgs","repos_url":"https://api.github.com/users/bem/repos","events_url":"https://api.github.com/users/bem/events{/privacy}","received_events_url":"https://api.github.com/users/bem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bem/bem-method","description":"BEM — a methodology how to develop web projects applicable for any technology","fork":false,"url":"https://api.github.com/repos/bem/bem-method","forks_url":"https://api.github.com/repos/bem/bem-method/forks","keys_url":"https://api.github.com/repos/bem/bem-method/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bem/bem-method/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bem/bem-method/teams","hooks_url":"https://api.github.com/repos/bem/bem-method/hooks","issue_events_url":"https://api.github.com/repos/bem/bem-method/issues/events{/number}","events_url":"https://api.github.com/repos/bem/bem-method/events","assignees_url":"https://api.github.com/repos/bem/bem-method/assignees{/user}","branches_url":"https://api.github.com/repos/bem/bem-method/branches{/branch}","tags_url":"https://api.github.com/repos/bem/bem-method/tags","blobs_url":"https://api.github.com/repos/bem/bem-method/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bem/bem-method/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bem/bem-method/git/refs{/sha}","trees_url":"https://api.github.com/repos/bem/bem-method/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bem/bem-method/statuses/{sha}","languages_url":"https://api.github.com/repos/bem/bem-method/languages","stargazers_url":"https://api.github.com/repos/bem/bem-method/stargazers","contributors_url":"https://api.github.com/repos/bem/bem-method/contributors","subscribers_url":"https://api.github.com/repos/bem/bem-method/subscribers","subscription_url":"https://api.github.com/repos/bem/bem-method/subscription","commits_url":"https://api.github.com/repos/bem/bem-method/commits{/sha}","git_commits_url":"https://api.github.com/repos/bem/bem-method/git/commits{/sha}","comments_url":"https://api.github.com/repos/bem/bem-method/comments{/number}","issue_comment_url":"https://api.github.com/repos/bem/bem-method/issues/comments{/number}","contents_url":"https://api.github.com/repos/bem/bem-method/contents/{+path}","compare_url":"https://api.github.com/repos/bem/bem-method/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bem/bem-method/merges","archive_url":"https://api.github.com/repos/bem/bem-method/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bem/bem-method/downloads","issues_url":"https://api.github.com/repos/bem/bem-method/issues{/number}","pulls_url":"https://api.github.com/repos/bem/bem-method/pulls{/number}","milestones_url":"https://api.github.com/repos/bem/bem-method/milestones{/number}","notifications_url":"https://api.github.com/repos/bem/bem-method/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bem/bem-method/labels{/name}","releases_url":"https://api.github.com/repos/bem/bem-method/releases{/id}","created_at":"2010-08-06T06:52:01Z","updated_at":"2015-10-31T12:08:27Z","pushed_at":"2015-11-06T10:06:20Z","git_url":"git://github.com/bem/bem-method.git","ssh_url":"git@github.com:bem/bem-method.git","clone_url":"https://github.com/bem/bem-method.git","svn_url":"https://github.com/bem/bem-method","homepage":"http://bem.info","size":29450,"stargazers_count":229,"watchers_count":229,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":67,"mirror_url":null,"open_issues_count":24,"forks":67,"open_issues":24,"watchers":229,"default_branch":"bem-info-data"}},"base":{"label":"bem:bem-info-data","ref":"bem-info-data","sha":"22ebe8bbe6864bfd31d6c2773468dee471b42662","user":{"login":"bem","id":223412,"avatar_url":"https://avatars.githubusercontent.com/u/223412?v=3","gravatar_id":"","url":"https://api.github.com/users/bem","html_url":"https://github.com/bem","followers_url":"https://api.github.com/users/bem/followers","following_url":"https://api.github.com/users/bem/following{/other_user}","gists_url":"https://api.github.com/users/bem/gists{/gist_id}","starred_url":"https://api.github.com/users/bem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bem/subscriptions","organizations_url":"https://api.github.com/users/bem/orgs","repos_url":"https://api.github.com/users/bem/repos","events_url":"https://api.github.com/users/bem/events{/privacy}","received_events_url":"https://api.github.com/users/bem/received_events","type":"Organization","site_admin":false},"repo":{"id":820900,"name":"bem-method","full_name":"bem/bem-method","owner":{"login":"bem","id":223412,"avatar_url":"https://avatars.githubusercontent.com/u/223412?v=3","gravatar_id":"","url":"https://api.github.com/users/bem","html_url":"https://github.com/bem","followers_url":"https://api.github.com/users/bem/followers","following_url":"https://api.github.com/users/bem/following{/other_user}","gists_url":"https://api.github.com/users/bem/gists{/gist_id}","starred_url":"https://api.github.com/users/bem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bem/subscriptions","organizations_url":"https://api.github.com/users/bem/orgs","repos_url":"https://api.github.com/users/bem/repos","events_url":"https://api.github.com/users/bem/events{/privacy}","received_events_url":"https://api.github.com/users/bem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bem/bem-method","description":"BEM — a methodology how to develop web projects applicable for any technology","fork":false,"url":"https://api.github.com/repos/bem/bem-method","forks_url":"https://api.github.com/repos/bem/bem-method/forks","keys_url":"https://api.github.com/repos/bem/bem-method/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bem/bem-method/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bem/bem-method/teams","hooks_url":"https://api.github.com/repos/bem/bem-method/hooks","issue_events_url":"https://api.github.com/repos/bem/bem-method/issues/events{/number}","events_url":"https://api.github.com/repos/bem/bem-method/events","assignees_url":"https://api.github.com/repos/bem/bem-method/assignees{/user}","branches_url":"https://api.github.com/repos/bem/bem-method/branches{/branch}","tags_url":"https://api.github.com/repos/bem/bem-method/tags","blobs_url":"https://api.github.com/repos/bem/bem-method/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bem/bem-method/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bem/bem-method/git/refs{/sha}","trees_url":"https://api.github.com/repos/bem/bem-method/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bem/bem-method/statuses/{sha}","languages_url":"https://api.github.com/repos/bem/bem-method/languages","stargazers_url":"https://api.github.com/repos/bem/bem-method/stargazers","contributors_url":"https://api.github.com/repos/bem/bem-method/contributors","subscribers_url":"https://api.github.com/repos/bem/bem-method/subscribers","subscription_url":"https://api.github.com/repos/bem/bem-method/subscription","commits_url":"https://api.github.com/repos/bem/bem-method/commits{/sha}","git_commits_url":"https://api.github.com/repos/bem/bem-method/git/commits{/sha}","comments_url":"https://api.github.com/repos/bem/bem-method/comments{/number}","issue_comment_url":"https://api.github.com/repos/bem/bem-method/issues/comments{/number}","contents_url":"https://api.github.com/repos/bem/bem-method/contents/{+path}","compare_url":"https://api.github.com/repos/bem/bem-method/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bem/bem-method/merges","archive_url":"https://api.github.com/repos/bem/bem-method/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bem/bem-method/downloads","issues_url":"https://api.github.com/repos/bem/bem-method/issues{/number}","pulls_url":"https://api.github.com/repos/bem/bem-method/pulls{/number}","milestones_url":"https://api.github.com/repos/bem/bem-method/milestones{/number}","notifications_url":"https://api.github.com/repos/bem/bem-method/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bem/bem-method/labels{/name}","releases_url":"https://api.github.com/repos/bem/bem-method/releases{/id}","created_at":"2010-08-06T06:52:01Z","updated_at":"2015-10-31T12:08:27Z","pushed_at":"2015-11-06T10:06:20Z","git_url":"git://github.com/bem/bem-method.git","ssh_url":"git@github.com:bem/bem-method.git","clone_url":"https://github.com/bem/bem-method.git","svn_url":"https://github.com/bem/bem-method","homepage":"http://bem.info","size":29450,"stargazers_count":229,"watchers_count":229,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":67,"mirror_url":null,"open_issues_count":24,"forks":67,"open_issues":24,"watchers":229,"default_branch":"bem-info-data"}},"_links":{"self":{"href":"https://api.github.com/repos/bem/bem-method/pulls/338"},"html":{"href":"https://github.com/bem/bem-method/pull/338"},"issue":{"href":"https://api.github.com/repos/bem/bem-method/issues/338"},"comments":{"href":"https://api.github.com/repos/bem/bem-method/issues/338/comments"},"review_comments":{"href":"https://api.github.com/repos/bem/bem-method/pulls/338/comments"},"review_comment":{"href":"https://api.github.com/repos/bem/bem-method/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bem/bem-method/pulls/338/commits"},"statuses":{"href":"https://api.github.com/repos/bem/bem-method/statuses/878e3822c5df8688910ab0311d7ebcf54601bfc5"}}}}