Skip to content

Commit

Permalink
internal/api: s/lang_id/language_id
Browse files Browse the repository at this point in the history
  • Loading branch information
adambabik committed Jan 20, 2023
1 parent 1b2adb2 commit 7b74b63
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 76 deletions.
2 changes: 1 addition & 1 deletion internal/api/runme/parser/v1/parser.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum CellKind {
message Cell {
CellKind kind = 1;
string value = 2;
string lang_id = 3;
string language_id = 3;
map<string, string> metadata = 4;
}

Expand Down
16 changes: 8 additions & 8 deletions internal/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ func (s *parserServiceServer) Deserialize(_ context.Context, req *parserv1.Deser
cells := make([]*parserv1.Cell, 0, len(notebook.Cells))
for _, cell := range notebook.Cells {
cells = append(cells, &parserv1.Cell{
Kind: parserv1.CellKind(cell.Kind),
Value: cell.Value,
LangId: cell.LangID,
Metadata: stringifyMapValue(cell.Metadata),
Kind: parserv1.CellKind(cell.Kind),
Value: cell.Value,
LanguageId: cell.LanguageID,
Metadata: stringifyMapValue(cell.Metadata),
})
}

Expand All @@ -147,10 +147,10 @@ func (s *parserServiceServer) Serialize(_ context.Context, req *parserv1.Seriali
cells := make([]*editor.Cell, 0, len(req.Notebook.Cells))
for _, cell := range req.Notebook.Cells {
cells = append(cells, &editor.Cell{
Kind: editor.CellKind(cell.Kind),
Value: cell.Value,
LangID: cell.LangId,
Metadata: parseMapValue(cell.Metadata),
Kind: editor.CellKind(cell.Kind),
Value: cell.Value,
LanguageID: cell.LanguageId,
Metadata: parseMapValue(cell.Metadata),
})
}
data, err := editor.Serialize(&editor.Notebook{
Expand Down
18 changes: 9 additions & 9 deletions internal/document/editor/cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const (
// Cell resembles NotebookCellData from VS Code.
// https://github.com/microsoft/vscode/blob/085c409898bbc89c83409f6a394e73130b932add/src/vscode-dts/vscode.d.ts#L13715
type Cell struct {
Kind CellKind `json:"kind"`
Value string `json:"value"`
LangID string `json:"languageId"`
Metadata map[string]any `json:"metadata,omitempty"`
Kind CellKind `json:"kind"`
Value string `json:"value"`
LanguageID string `json:"languageId"`
Metadata map[string]any `json:"metadata,omitempty"`
}

// Notebook resembles NotebookData form VS Code.
Expand Down Expand Up @@ -105,10 +105,10 @@ func toCellsRec(
metadata := convertAttrsToMetadata(block.Attributes())
metadata[prefixAttributeName(internalAttributePrefix, "name")] = block.Name()
*cells = append(*cells, &Cell{
Kind: CodeKind,
Value: string(block.Content()),
LangID: block.Language(),
Metadata: metadata,
Kind: CodeKind,
Value: string(block.Content()),
LanguageID: block.Language(),
Metadata: metadata,
})
} else {
*cells = append(*cells, &Cell{
Expand Down Expand Up @@ -229,7 +229,7 @@ func serializeCells(cells []*Cell) []byte {
}

_, _ = buf.Write(bytes.Repeat([]byte{'`'}, ticksCount))
_, _ = buf.WriteString(cell.LangID)
_, _ = buf.WriteString(cell.LanguageID)

serializeFencedCodeAttributes(&buf, cell)

Expand Down
111 changes: 56 additions & 55 deletions internal/gen/proto/go/runme/parser/v1/parser.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/gen/proto/ts/runme/parser/v1/parser_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export class Cell extends Message<Cell> {
value = "";

/**
* @generated from field: string lang_id = 3;
* @generated from field: string language_id = 3;
*/
langId = "";
languageId = "";

/**
* @generated from field: map<string, string> metadata = 4;
Expand All @@ -109,7 +109,7 @@ export class Cell extends Message<Cell> {
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "kind", kind: "enum", T: proto3.getEnumType(CellKind) },
{ no: 2, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "lang_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "language_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "metadata", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} },
]);

Expand Down

0 comments on commit 7b74b63

Please sign in to comment.