diff --git a/capibara-website/app/models/Function.scala b/capibara-website/app/models/Function.scala index 6af7e60..99b1fcb 100644 --- a/capibara-website/app/models/Function.scala +++ b/capibara-website/app/models/Function.scala @@ -9,6 +9,10 @@ object Parameter { implicit val parameterFormatter = Json.format[Parameter]; } +object Example { + implicit val exampleFormatter = Json.format[Example]; +} + object Function { implicit val functionFormatter = Json.format[Function]; } @@ -20,6 +24,7 @@ case class Function( returns: Return, parameters: Seq[Parameter], description: String, + examples: Seq[Example], associated: Seq[String], os_affinity: Seq[String] ) @@ -33,4 +38,9 @@ case class Parameter( name: String, `type`: String, description: String, -) \ No newline at end of file +) + +case class Example( + title: String, + code: String, +) diff --git a/capibara-website/app/models/Macro.scala b/capibara-website/app/models/Macro.scala index f92010b..a115d86 100644 --- a/capibara-website/app/models/Macro.scala +++ b/capibara-website/app/models/Macro.scala @@ -10,6 +10,10 @@ object MacroParameter { implicit val parameterFormatter = Json.format[MacroParameter]; } +object MacroExample { + implicit val parameterFormatter = Json.format[MacroExample]; +} + object MacroFunction { implicit val functionFormatter = Json.format[MacroFunction]; } @@ -43,7 +47,8 @@ case class MacroKind( case class MacroFunction( returns: MacroReturn, - parameters: Seq[MacroParameter] + parameters: Seq[MacroParameter], + examples: Seq[MacroExample] ) case class MacroReturn( @@ -55,3 +60,8 @@ case class MacroParameter( name: String, description: String ) + +case class MacroExample( + title: String, + code: String, +) diff --git a/clientapp/src/pages/capi/definitions/CapiFunction.js b/clientapp/src/pages/capi/definitions/CapiFunction.js index 3c092f2..ac405dc 100644 --- a/clientapp/src/pages/capi/definitions/CapiFunction.js +++ b/clientapp/src/pages/capi/definitions/CapiFunction.js @@ -15,6 +15,17 @@ export default function CapiFunction({ fn }) { ); }); + const examples = fn.examples.map((e) => { + return ( + <> +