Docs

Tools for generating a versioned documentation site from YARD docs.

Class: SleepingKingStudios::Docs::Data::NamespaceObject

Parent Namespace
SleepingKingStudios::Docs::Data
Inherited Classes
SleepingKingStudios::Docs::Data::Base > Object
Defined In
lib/sleeping_king_studios/docs/data/namespace_object.rb

Table Of Contents

Overview

Object representing a Ruby namespace.

Each namespace can define the following elements:

In most cases, there should be one documented namespace, reflecting the top-level namespace, and in most cases should only include defined classes and/or modules. Top-level constants may be required on a case-by-case basis.

All other namespace properties (attributes and methods) should be reserved for classes and modules, whose representation inherits from NamespaceObject.

See Also

Back To Top

Direct Subclasses

SleepingKingStudios::Docs::Data::ModuleObject, SleepingKingStudios::Docs::Data::RootObject

Back To Top

Constructor

#initialize(native:) => Base

Inherited From
SleepingKingStudios::Docs::Data::Base

Parameters

Returns

Back To Top

Instance Methods

#as_json => Hash{String => Object}

Generates a JSON-compatible representation of the namespace.

Returns a Hash with the following keys:

Additionally, the returned Hash will conditionally include the following keys, if the namespace defines at least one of the corresponding code objects.

Returns

#class_attributes => Array<Hash>

Finds the class attributes defined for the namespace.

For each class attribute, it returns a Hash with the following keys:

Returns

#class_methods => Array<Hash{String => String}>

Finds the class methods defined for the namespace.

For each method, it returns a Hash with the following keys:

Returns

#constants => Array<String>

Finds the names of the constants defined under this namespace.

Returns

#defined_classes => Array<Hash>

Finds the Classes defined under this namespace, if any.

For each defined Class, it returns a Hash with the following keys:

Examples

# Given a class LaunchWindow in the namespace Space::Operations:
namespace.name
#=> 'Space::Operations'
namespace.defined_classes
#=> [{ 'name' => 'LaunchWindow', 'slug' => 'launch-window' }]

Returns

#defined_modules => Array<Hash>

Finds the Modules defined under this namespace, if any.

For each defined Module, it returns a Hash with the following keys:

Examples

# Given a class FuelConsumer in the namespace Space::Engineering:
namespace.name
#=> 'Space::Engineering'
namespace.defined_classes
#=> [{ 'name' => 'FuelConsumer', 'slug' => 'fuel-consumer' }]

Returns

#instance_attributes => Array<Hash>

Finds the instance attributes defined for the namespace.

For each instance attribute, it returns a Hash with the following keys:

Returns

#instance_methods => Array<Hash{String => String}>

Finds the instance methods defined for the namespace.

For each method, it returns a Hash with the following keys:

Returns

#name => String

The full, qualified name of the namespace.

For the root namespace, should return an empty string. For a Class or a Module, should return the full name, e.g. “MyGem::MyModule::MyClass”.

Returns

#slug => String

The name of the namespace in url-safe format.

Returns

#type => String

Returns

Back To Top


Back to Documentation | Versions | 0.2 | Reference | SleepingKingStudios | SleepingKingStudios::Docs | SleepingKingStudios::Docs::Data