Skip to content

Commit

Permalink
Merge pull request #380 from apiaryio/kylef/clang-format
Browse files Browse the repository at this point in the history
Conform to our clang-format
  • Loading branch information
pksunkara committed Aug 10, 2017
2 parents 9dcf6e2 + 56515c7 commit afd966f
Show file tree
Hide file tree
Showing 91 changed files with 4,851 additions and 4,449 deletions.
74 changes: 74 additions & 0 deletions .clang-format
@@ -0,0 +1,74 @@
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: false
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: false
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 4
UseTab: Never
SortIncludes: false

243 changes: 118 additions & 125 deletions src/ActionParser.h

Large diffs are not rendered by default.

37 changes: 21 additions & 16 deletions src/AssetParser.h
Expand Up @@ -13,10 +13,12 @@
#include "RegexMatch.h"
#include "CodeBlockUtility.h"

namespace snowcrash {
namespace snowcrash
{

/// Asset signature
enum AssetSignature {
enum AssetSignature
{
NoAssetSignature = 0,
BodyAssetSignature, /// < Explicit body asset
ImplicitBodyAssetSignature, /// < Body asset using abbreviated syntax
Expand All @@ -33,14 +35,15 @@ namespace snowcrash {
/**
* Asset Section Processor
*/
template<>
template <>
struct SectionProcessor<Asset> : public SectionProcessorBase<Asset> {

static MarkdownNodeIterator processSignature(const MarkdownNodeIterator& node,
const MarkdownNodes& siblings,
SectionParserData& pd,
SectionLayout& layout,
const ParseResultRef<Asset>& out) {
const MarkdownNodes& siblings,
SectionParserData& pd,
SectionLayout& layout,
const ParseResultRef<Asset>& out)
{

out.node = "";
CodeBlockUtility::signatureContentAsCodeBlock(node, pd, out.report, out.node);
Expand All @@ -55,9 +58,10 @@ namespace snowcrash {
NO_SECTION_DESCRIPTION(Asset)

static MarkdownNodeIterator processContent(const MarkdownNodeIterator& node,
const MarkdownNodes& siblings,
SectionParserData& pd,
const ParseResultRef<Asset>& out) {
const MarkdownNodes& siblings,
SectionParserData& pd,
const ParseResultRef<Asset>& out)
{

mdp::ByteBuffer content;
CodeBlockUtility::contentAsCodeBlock(node, pd, out.report, content);
Expand All @@ -71,15 +75,15 @@ namespace snowcrash {
return ++MarkdownNodeIterator(node);
}

static bool isContentNode(const MarkdownNodeIterator& node,
SectionType sectionType) {
static bool isContentNode(const MarkdownNodeIterator& node, SectionType sectionType)
{

return (SectionKeywordSignature(node) == UndefinedSectionType);
}

static SectionType sectionType(const MarkdownNodeIterator& node) {
if (node->type == mdp::ListItemMarkdownNodeType
&& !node->children().empty()) {
static SectionType sectionType(const MarkdownNodeIterator& node)
{
if (node->type == mdp::ListItemMarkdownNodeType && !node->children().empty()) {

AssetSignature signature = assetSignature(node);

Expand All @@ -100,7 +104,8 @@ namespace snowcrash {
}

/** Resolve asset signature */
static AssetSignature assetSignature(const MarkdownNodeIterator& node) {
static AssetSignature assetSignature(const MarkdownNodeIterator& node)
{

mdp::ByteBuffer remaining, subject = node->children().front().text;
subject = GetFirstLine(subject, remaining);
Expand Down
63 changes: 34 additions & 29 deletions src/AttributesParser.h
Expand Up @@ -14,32 +14,34 @@

using namespace scpl;

namespace snowcrash {
namespace snowcrash
{

/** Attributes matching regex */
const char* const AttributesRegex = "^[[:blank:]]*[Aa]ttributes?[[:blank:]]*(\\(.*\\))?$";

/**
* Attributes section processor
*/
template<>
template <>
struct SectionProcessor<Attributes> : public SignatureSectionProcessorBase<Attributes> {

static SignatureTraits signatureTraits() {
static SignatureTraits signatureTraits()
{

SignatureTraits signatureTraits(SignatureTraits::IdentifierTrait |
SignatureTraits::AttributesTrait);
SignatureTraits signatureTraits(SignatureTraits::IdentifierTrait | SignatureTraits::AttributesTrait);

return signatureTraits;
}

static MarkdownNodeIterator finalizeSignature(const MarkdownNodeIterator& node,
SectionParserData& pd,
const Signature& signature,
const ParseResultRef<Attributes>& out) {
SectionParserData& pd,
const Signature& signature,
const ParseResultRef<Attributes>& out)
{

if (!IEqual<std::string>()(signature.identifier, "Attribute") &&
!IEqual<std::string>()(signature.identifier, "Attributes")) {
if (!IEqual<std::string>()(signature.identifier, "Attribute")
&& !IEqual<std::string>()(signature.identifier, "Attributes")) {

return node;
}
Expand All @@ -51,7 +53,7 @@ namespace snowcrash {
if (!out.node.typeDefinition.empty()) {
out.sourceMap.typeDefinition.sourceMap = node->sourceMap;
}

out.sourceMap.sourceMap = node->sourceMap;
}

Expand All @@ -60,42 +62,44 @@ namespace snowcrash {
out.node.typeDefinition.baseType = mson::ImplicitObjectBaseType;
}

SectionProcessor<mson::ValueMember>::parseRemainingContent(node, pd, signature.remainingContent,
out.node.sections, out.sourceMap.sections);
SectionProcessor<mson::ValueMember>::parseRemainingContent(
node, pd, signature.remainingContent, out.node.sections, out.sourceMap.sections);

return ++MarkdownNodeIterator(node);
}

static MarkdownNodeIterator processDescription(const MarkdownNodeIterator& node,
const MarkdownNodes& siblings,
SectionParserData& pd,
const ParseResultRef<Attributes>& out) {
const MarkdownNodes& siblings,
SectionParserData& pd,
const ParseResultRef<Attributes>& out)
{

return SectionProcessor<mson::ValueMember>::blockDescription(node, pd, out.node.sections, out.sourceMap.sections);
return SectionProcessor<mson::ValueMember>::blockDescription(
node, pd, out.node.sections, out.sourceMap.sections);
}

static MarkdownNodeIterator processNestedSection(const MarkdownNodeIterator& node,
const MarkdownNodes& siblings,
SectionParserData& pd,
const ParseResultRef<Attributes>& out) {
const MarkdownNodes& siblings,
SectionParserData& pd,
const ParseResultRef<Attributes>& out)
{

ParseResultRef<mson::TypeSections> typeSections(out.report, out.node.sections, out.sourceMap.sections);

return SectionProcessor<mson::ValueMember>
::processNestedMembers<MSONTypeSectionListParser>(node, siblings, pd, typeSections,
out.node.typeDefinition.baseType);
return SectionProcessor<mson::ValueMember>::processNestedMembers<MSONTypeSectionListParser>(
node, siblings, pd, typeSections, out.node.typeDefinition.baseType);
}

static bool isDescriptionNode(const MarkdownNodeIterator& node,
SectionType sectionType) {
static bool isDescriptionNode(const MarkdownNodeIterator& node, SectionType sectionType)
{

return SectionProcessor<mson::ValueMember>::isDescriptionNode(node, sectionType);
}

static SectionType sectionType(const MarkdownNodeIterator& node) {
static SectionType sectionType(const MarkdownNodeIterator& node)
{

if (node->type == mdp::ListItemMarkdownNodeType &&
!node->children().empty()) {
if (node->type == mdp::ListItemMarkdownNodeType && !node->children().empty()) {

mdp::ByteBuffer remaining, subject = node->children().front().text;

Expand All @@ -110,7 +114,8 @@ namespace snowcrash {
return UndefinedSectionType;
}

static SectionType nestedSectionType(const MarkdownNodeIterator& node) {
static SectionType nestedSectionType(const MarkdownNodeIterator& node)
{

return SectionProcessor<mson::ValueMember>::nestedSectionType(node);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Blueprint.cc
Expand Up @@ -10,7 +10,7 @@

using namespace snowcrash;

DataStructure& DataStructure::operator=(const mson::NamedType &rhs)
DataStructure& DataStructure::operator=(const mson::NamedType& rhs)
{
this->name = rhs.name;
this->typeDefinition = rhs.typeDefinition;
Expand Down Expand Up @@ -62,8 +62,7 @@ Element::Content::~Content()
{
}

Element::Element(const Element::Class& element_)
: element(element_)
Element::Element(const Element::Class& element_) : element(element_)
{
}

Expand Down
42 changes: 25 additions & 17 deletions src/Blueprint.h
Expand Up @@ -23,7 +23,8 @@
* Data types in this documents define the API Blueprint AST.
*/

namespace snowcrash {
namespace snowcrash
{

/** Name of a an API Blueprint entity. */
typedef std::string Name;
Expand Down Expand Up @@ -77,7 +78,7 @@ namespace snowcrash {
* FIXME: Use C++11 template aliases when migrating to C++11.
*/

template<typename T>
template <typename T>
struct Collection {
typedef std::vector<T> type;
typedef typename std::vector<T>::iterator iterator;
Expand All @@ -94,14 +95,16 @@ namespace snowcrash {
typedef Collection<Value>::type Values;

/** Role of an element */
enum AssetRole {
UndefinedAssetRole = 0, // Unknown
BodyExampleAssetRole, // Body example for asset
BodySchemaAssetRole // Body schema for asset
enum AssetRole
{
UndefinedAssetRole = 0, // Unknown
BodyExampleAssetRole, // Body example for asset
BodySchemaAssetRole // Body schema for asset
};

/** Parameter Use flag */
enum ParameterUse {
enum ParameterUse
{
UndefinedParameterUse,
OptionalParameterUse,
RequiredParameterUse
Expand Down Expand Up @@ -146,15 +149,17 @@ namespace snowcrash {
struct Reference {

/** Reference Resolution State */
enum State {
StateUnresolved, // Reference unresolved (undefined)
StatePending, // Reference resolution pending
StateResolved // Reference resolved successfully
enum State
{
StateUnresolved, // Reference unresolved (undefined)
StatePending, // Reference resolution pending
StateResolved // Reference resolved successfully
};

/** Reference Type */
enum ReferenceType {
ModelReference // Resource Model as a reference
enum ReferenceType
{
ModelReference // Resource Model as a reference
};

/** Identifier */
Expand All @@ -166,8 +171,9 @@ namespace snowcrash {
struct ReferenceMetadata {

/** Constructor */
ReferenceMetadata(State state_ = StateUnresolved)
: state(state_) {}
ReferenceMetadata(State state_ = StateUnresolved) : state(state_)
{
}

/** Markdown AST reference source node (for source map) */
mdp::MarkdownNodeIterator node;
Expand Down Expand Up @@ -375,7 +381,8 @@ namespace snowcrash {
struct Element {

/** Class of an element */
enum Class {
enum Class
{
UndefinedElement = 0, // Unknown
CategoryElement, // Group of other elements
CopyElement, // Human readable text
Expand Down Expand Up @@ -424,7 +431,8 @@ namespace snowcrash {
};

/** Type of Category element (parser internal flag) */
enum Category {
enum Category
{
UndefinedCategory = 0, // Unknown
ResourceGroupCategory, // Resource Group
DataStructureGroupCategory // Data Structure Group
Expand Down

0 comments on commit afd966f

Please sign in to comment.