Problem/Motivation

One drawback of the content model documentation at this time is that a field or entity has to exist before it can be documented so it prevents documentation from riding along with the code that created the thing to document.

As a site developer it would be nice to be able to create a Content Model Document locally and then be able to export and initialize the import.

The import should not be a sync, only imported once, then maintained as content on the prod instance of Drupal.

Some possibilities:

  • Export with a copyable array that could then be pasted into a hook_update_N which would instantiate the document with the initial values. Drawback: this only solves the initial case of creating the document, not making changes to it as new code is released.
  • Tome sync
  • content import with some kind of import.
  • A migration from a csv or other data source? (would still need a way to export)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

swirt created an issue. See original summary.

  • swirt committed 458be617 on 1.0.x
    Issue #3393426: Make documentation exportable importable
    
swirt’s picture

Status: Active » Fixed

This feature has been added.

The module now has a built in system for exporting CM Documents from you local environment and having them import into your production site when your code deploys.

Drush commands

  • Export: drush content-model-documentation:export <id>
  • Import:
    drush content-model-documentation:import '/alias/of/the/cm-document'
    

hook_update_n()

    use Drupal\content_model_documentation\CmDocumentMover\CmDocumentImport;

    /**
     * Import some CM Documents.
    */
    function <local_module>_update_9017() {
      $cm_documents_to_import = [
        '/admin/structure/types/manage/promo_banner/document',
        '/admin/structure/types/manage/full_width_banner_alert/document',
      ];
      // If set to true, the hook_update calls itself a failure if any of the documents are rejected.  Setting to FALSE causes the hook_update to call itself complete even if a document(s) get rejected.
      $strict = TRUE;
      return CmDocumentImport::import($cm_documents_to_import, $strict);
    }


See the module help page / readme for step by steps.
swirt’s picture

Status: Fixed » Closed (fixed)

Went out with 1.0.21