code: def run(self):
      size = self.options.get("size", 15)
      names = [
          name.strip()
          for name in self.options.get("names", "").split(",")
      ]
      indices = self.options.get("indices", [])
      shuffle = "shuffle" in self.options
      seed = self.options.get("seed", 42)
      titles = self.options.get("titles", False)
      width = self.options.get("width", None)
  
      env = self.state.document.settings.env
      app = env.app
  
      gallery_dir = app.builder.config.altair_gallery_dir
  
      examples = populate_examples()
  
      if names:
          if len(names) < size:
              raise ValueError(
                  "altair-minigallery: if names are specified, "
                  "the list must be at least as long as size."
              )
          mapping = {example["name"]: example for example in examples}
          examples = [mapping[name] for name in names]
      else:
          if indices:
              examples = [examples[i] for i in indices]
          if shuffle:
              random.seed(seed)
              random.shuffle(examples)
          if size:
              examples = examples[:size]
  
      include = MINIGALLERY_TEMPLATE.render(
          image_dir="/_static",
          gallery_dir=gallery_dir,
          examples=examples,
          titles=titles,
          width=width,
      )
  
      # parse and return documentation
      result = ViewList()
      for line in include.split("\n"):
          result.append(line, "<altair-minigallery>")
      node = nodes.paragraph()
      node.document = self.state.document
      nested_parse_with_titles(self.state, result, node)
  
      return node.children
  
imports: import hashlib
  import os
  import json
  import random
  import collections
  from operator import itemgetter
  import warnings
  import shutil
  import jinja2
  from docutils import nodes
  from docutils.statemachine import ViewList
  from docutils.parsers.rst import Directive
  from docutils.parsers.rst.directives import flag
  from sphinx.util.nodes import nested_parse_with_titles
  from .utils import get_docstring_and_rest, prev_this_next, create_thumbnail, create_generic_image
  from altair.utils.execeval import eval_block
  from tests.examples_arguments_syntax import iter_examples_arguments_syntax
  from tests.examples_methods_syntax import iter_examples_methods_syntax
label_desc: Use image node_id 1 for calling the AltairMiniGalleryDirective obj's underlying member method code with example usage: obj.run() and returns: node