@staticmethod
def spec_to_yaml(spec):
    """
        Convert a given specification to yaml. Used by the add_spec function to render a spec
        as YAML in the RST document

        :param spec: Specification data structure
        :type spec: GroupSpec, DatasetSpec, AttributeSpec, LinkSpec

        :return: YAML string for the current specification
        """
    import json
    import sys
    try:
        from ruamel import yaml
    except ImportError:
        import yaml
    clean_spec = json.loads(json.dumps(spec, sort_keys=True, indent=4,
        separators=(',', ': ')))
    if sys.version_info[0] == 3:
        return yaml.dump(clean_spec, default_flow_style=False)
    else:
        return yaml.safe_dump(clean_spec, default_flow_style=False)
