chore(docs): SDK page cleanup — sidebar, examples, tab naming, code structure#277
chore(docs): SDK page cleanup — sidebar, examples, tab naming, code structure#277marythought wants to merge 27 commits intomainfrom
Conversation
…tructure (#274) 1. Sidebar: reorder to logical flow — Architecture → Authentication → Quickstart → TDF → Policy → Obligations → Authorization → Discovery → Troubleshooting 2. TDF: rename Quick Start to Setup, move usage examples after Parameters (before Returns/Errors) for CreateTDF, LoadTDF, IsValidTdf, BulkDecrypt 3. Tab naming: standardize all JS/TS tabs to "JavaScript" 4. Code structure: add Setup sections to Authentication, TDF, Policy, and Obligations pages. Strip SDK init boilerplate from all Policy inline examples and imported code samples. Extract Obligations into its own page (different service accessor, Go + JS only). Closes #274 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughStandardizes SDK docs: renames TypeScript tabs to JavaScript, centralizes/assumes shared setup (removes inline auth/client boilerplate), restructures several SDK pages (authorization, discovery, tdf), adds Signature/Parameters/Returns blocks, adjusts sidebar ordering, adds Obligations SDK page, and extends OpenAPI with attribute-sorting schemas. Changes
Sequence Diagram(s)(No sequence diagrams generated — changes are documentation and schema additions without new multi-component runtime control flow to visualize.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
📄 Preview deployed to https://opentdf-docs-pr-277.surge.sh |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
docs/sdks/obligations.mdx (1)
46-46: Usejavascriptcode fence under JavaScript tabsThe tab is labeled “JavaScript”, but the fence is
typescript. Since these snippets are plain JS, switching tojavascriptwill avoid mixed signaling.Suggested change
-```typescript +```javascript import { PlatformClient } from '@opentdf/sdk/platform';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/sdks/obligations.mdx` at line 46, The JavaScript tab in docs/sdks/obligations.mdx currently uses a ```typescript code fence; change that fence to ```javascript so the snippet (e.g., the import line "import { PlatformClient } from '@opentdf/sdk/platform';") is correctly labeled as JavaScript; update any matching opening/closing fences in the same snippet to maintain consistent fences within the JavaScript tab.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code_samples/policy_code/create_subject_mapping.mdx`:
- Around line 25-29: The if-statement that checks the result of
client.SubjectMapping.CreateSubjectMapping (the block starting with "if err !=
nil {") is missing its closing brace; fix by adding the matching "}" after the
log.Fatal(err) line so the error-handling block around err and log.Fatal is
properly closed for CreateSubjectMapping.
In `@code_samples/policy_code/list_attributes.mdx`:
- Around line 19-25: The outer for loop iterating over attrs.GetAttributes() is
missing its closing brace; add a closing "}" after the inner loop (after the
log.Printf for each value) to close the block that starts with "for _, attr :=
range attrs.GetAttributes()" so the snippet compiles correctly; locate the loop
by the identifier attrs.GetAttributes(), the loop variable attr, and the inner
loop over attr.Values.
In `@code_samples/policy_code/list_namespaces.mdx`:
- Around line 17-20: The Go snippet opens a for loop over
namespaces.GetNamespaces() but never closes it; add the missing closing brace
'}' immediately after the log.Printf("Namespace: %s\n", namespace.GetName())
line to properly terminate the for loop that iterates using namespace.GetName()
and namespaces.GetNamespaces().
---
Nitpick comments:
In `@docs/sdks/obligations.mdx`:
- Line 46: The JavaScript tab in docs/sdks/obligations.mdx currently uses a
```typescript code fence; change that fence to ```javascript so the snippet
(e.g., the import line "import { PlatformClient } from
'@opentdf/sdk/platform';") is correctly labeled as JavaScript; update any
matching opening/closing fences in the same snippet to maintain consistent
fences within the JavaScript tab.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d2b3c66c-6f87-465e-bade-c451b6e1f670
📒 Files selected for processing (18)
code_samples/authorization/get_decision.mdxcode_samples/authorization/get_entitlements.mdxcode_samples/policy_code/create_attribute.mdxcode_samples/policy_code/create_namespace.mdxcode_samples/policy_code/create_subject_condition_set.mdxcode_samples/policy_code/create_subject_mapping.mdxcode_samples/policy_code/list_attributes.mdxcode_samples/policy_code/list_namespaces.mdxcode_samples/policy_code/list_subject_mapping.mdxdocs/sdks/authentication.mdxdocs/sdks/authorization.mdxdocs/sdks/discovery.mdxdocs/sdks/obligations.mdxdocs/sdks/platform-client.mdxdocs/sdks/policy.mdxdocs/sdks/quickstart/_category_.jsondocs/sdks/tdf.mdxdocs/sdks/troubleshooting.mdx
There was a problem hiding this comment.
Code Review
This pull request updates the SDK documentation by adding a new page for Obligations, reorganizing sidebar positions, and simplifying Go code snippets across various policy code samples. It also standardizes the labeling of JavaScript code blocks. Review feedback correctly identified several syntax errors in the updated Go snippets, specifically missing closing braces for conditional statements and loops in the 'create_subject_mapping', 'list_attributes', and 'list_namespaces' samples.
| if err != nil { | ||
| log.Fatal(err) | ||
|
|
There was a problem hiding this comment.
Fixed in a subsequent commit.
| for _, attr := range attrs.GetAttributes() { | ||
| log.Printf("Attribute: %s, ID: %s, ", attr.GetName(), attr.GetId()) | ||
| for _, value := range attr.Values { | ||
| log.Printf("Value: %s, ID: %s", value.GetValue(), value.GetId()) | ||
| } | ||
|
|
There was a problem hiding this comment.
There was a problem hiding this comment.
Fixed in a subsequent commit.
| for _, namespace := range namespaces.GetNamespaces() { | ||
| log.Printf("Namespace: %s\n", namespace.GetName()) | ||
|
|
There was a problem hiding this comment.
Fixed in a subsequent commit.
…#274) - Add Signature, Parameters table, and Returns description to all 5 namespace operations (Create, List, Get, Update, Deactivate) as a proof of concept for the structured pattern used on the TDF page - Link DEK reference to protocol spec on TDF assertions page - Link Policy intro to concept overview page Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…#274) Replace abbreviated `// Imports: namespaces` comments with full Go import paths so each snippet shows the correct platform protocol import. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update authorization and attributes specs from opentdf/platform main. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
❌ Surge preview build failed — no preview was deployed. Check the workflow logs for details. Once the build passes, the preview will be at: https://opentdf-docs-pr-277.surge.sh Common cause: If the build failed on vendored YAML validation, run the following locally and commit the result: |
- Rename "Authentication Setup" to "Setup" for consistency - Strip package-specific imports from Setup section - Add actual Go import statements to each code example where packages are used (authorization, authorizationv2, entity, policy, proto) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
WithComprehensiveHierarchy is available in the v2 API — the comment claiming it was v1-only was incorrect. Update Go example to use authorizationv2.ForEmail() helper and client.AuthorizationV2. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rename sections to method names: GetEntitlements, GetDecision, GetDecisionBulk - Add Signature, Parameters, and Returns to each method - Merge "Entitlements with Scope" into GetEntitlements as a second example rather than a separate section - Merge token-based example into GetDecision - Move Entity Identifier Helpers table into Setup section - Consolidate Real-World Examples into Best Practices - Simplify Error Handling section Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add Setup section with client init for Go, Java, JS - Add Signature, Parameters, and Returns to all 5 methods (ListAttributes, AttributeExists, AttributeValueExists, ValidateAttributes, GetEntityAttributes) - Strip inline JS auth setup from examples (now in Setup) - Strip client init from "Putting It Together" examples - Keep method-name headings (already correct) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…up (#274) - Add Namespace, Attribute, Attribute Value, Subject Condition Set, and Subject Mapping object reference tables to Policy page - Add shared Metadata section explaining the labels structure - Simplify parameter types (MetadataMutable → object, ActiveStateEnum → string, MetadataUpdateEnum → string with actual enum values) - Add metadata and pagination examples to Create/List Namespace - Link DEK reference to protocol spec on TDF page - Restructure Discovery page with Setup + Signature/Parameters/Returns - Restructure Authorization page with method-name headings - Update Entitlements with Scope to use v2 API Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ions (#274) Add structured documentation to all 11 attribute operations: - Create, List, Get, Update, Deactivate Attribute - Create, List, Get, Get by FQNs, Update, Deactivate Attribute Value Each operation now has Signature, Parameters table, Example, and Returns with links to type reference tables. Stray JS auth imports removed from snippets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code_samples/policy_code/create_attribute.mdx`:
- Around line 30-35: The sample uses rand.Text()[:4] (in the attrRequest
creation) which requires Go 1.24+; replace that call with a Go 1.21-compatible
random suffix (for example, generate 4 random bytes via crypto/rand.Read and
encode them (hex or base64) then take the needed prefix) when building the Name
("role-" + <suffix>), or alternatively update the quickstart docs to require Go
1.24+; update the CreateAttributeRequest Name construction to use the new suffix
method and keep the rest of attrRequest (NamespaceId, Rule, Values) unchanged.
In `@code_samples/policy_code/list_namespaces.mdx`:
- Around line 64-72: The example uses policy.PageRequest in the ListNamespaces
call but the code sample's imports do not include the policy package, causing a
compile error; fix by adding the proper import for the policy package used by
PageRequest (or update the reference to the fully-qualified package alias) so
that ListNamespaces(context.Background(), &namespaces.ListNamespacesRequest{
State: common.ActiveStateEnum_ACTIVE_STATE_ENUM_INACTIVE, Pagination:
&policy.PageRequest{ ... } }) resolves—ensure the package alias matches the rest
of the file and the PageRequest type (e.g., import the package that defines
PageRequest or change policy.PageRequest to the correct package alias).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b139876e-f841-41dc-86b9-981372e79964
📒 Files selected for processing (13)
code_samples/policy_code/create_attribute.mdxcode_samples/policy_code/create_namespace.mdxcode_samples/policy_code/create_subject_condition_set.mdxcode_samples/policy_code/create_subject_mapping.mdxcode_samples/policy_code/list_attributes.mdxcode_samples/policy_code/list_namespaces.mdxcode_samples/policy_code/list_subject_mapping.mdxdocs/sdks/authorization.mdxdocs/sdks/discovery.mdxdocs/sdks/policy.mdxdocs/sdks/tdf.mdxspecs/authorization/authorization.openapi.yamlspecs/policy/attributes/attributes.openapi.yaml
✅ Files skipped from review due to trivial changes (2)
- specs/authorization/authorization.openapi.yaml
- docs/sdks/authorization.mdx
🚧 Files skipped from review as they are similar to previous changes (3)
- code_samples/policy_code/create_subject_mapping.mdx
- docs/sdks/discovery.mdx
- docs/sdks/tdf.mdx
#274) Add structured documentation to all Subject Condition Set operations (Create, List, Get, Update, Delete, Delete All Unmapped) and all Subject Mapping operations (Create, List, Get, Update, Delete, Match). Each operation now has Signature, Parameters table, Example, and Returns with links to type reference tables. Stray JS auth imports removed from snippets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…example CodeRabbit flagged that policy.PageRequest was used without importing the policy package. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the PageResponse fields (currentOffset, nextOffset, total) in a shared Pagination section. Link all List operation Returns to it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code_samples/policy_code/create_attribute.mdx`:
- Line 40: The `values` parameter description in the table is a sentence
fragment; update the text for the `values` row so it reads as a complete
sentence (for example: "Initial values to create with the attribute. Values can
also be added later via Create an Attribute Value.") so the second clause is a
full sentence and references the Create an Attribute Value anchor.
In `@code_samples/policy_code/create_subject_mapping.mdx`:
- Around line 67-69: The snippet calling
client.SubjectMapping.CreateSubjectMapping currently uses "_, err = ..." which
fails because err isn't declared; change the assignment to use short declaration
"_, err :=" so the CreateSubjectMapping call
(client.SubjectMapping.CreateSubjectMapping(context.Background(),
subjectMapping)) declares and assigns err in one statement, making the example
self-contained and copy-paste runnable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6fd347b8-2c90-4820-925b-d6785d37d640
📒 Files selected for processing (7)
code_samples/policy_code/create_attribute.mdxcode_samples/policy_code/create_subject_condition_set.mdxcode_samples/policy_code/create_subject_mapping.mdxcode_samples/policy_code/list_attributes.mdxcode_samples/policy_code/list_namespaces.mdxcode_samples/policy_code/list_subject_mapping.mdxdocs/sdks/policy.mdx
✅ Files skipped from review due to trivial changes (1)
- code_samples/policy_code/list_subject_mapping.mdx
🚧 Files skipped from review as they are similar to previous changes (2)
- code_samples/policy_code/list_namespaces.mdx
- code_samples/policy_code/list_attributes.mdx
Add Response Objects section to the Architecture page showing how to access fields in Go (Get* getters), Java (get* getters), and JS (direct property access). Four examples: GetAttributeValue, ListAttributeValues, GetDecision, GetEntitlements. Also: fix short-form enum refs, add FQN uniqueness note, add SubjectProperty type reference, and various small cleanups. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add detailed type references for SubjectSet, ConditionGroup, and Condition with an ASCII tree showing how they nest, evaluation logic explanation, operator reference table, and a concrete JSON example. This is the part of policy that confuses people the most — now it's fully documented. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…274) - Add "Related Objects in Responses" section to Architecture page showing the GetSubjectConditionSet → associatedSubjectMappings pattern with examples in all 3 languages - Add missing namespaceId/namespaceFqn filter params to ListSubjectConditionSets and ListSubjectMappings Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only one API uses this pattern — better documented on the Policy page where GetSubjectConditionSet lives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace opaque SubjectConditionSetCreate type with object description and link to the Condition Structure docs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace all `object` type references for metadata with linked `Metadata` type pointing to the shared Metadata section. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the four standard actions (read, create, update, delete) and custom action support. Show the name-based API for all three languages. Link Subject Mapping Object and parameter tables to the Action type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the EntityIdentifier structure for all three languages — Go helpers, Java proto builders, and JS oneof syntax. Include a cross-reference table mapping entity types to each SDK's API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document Decision, ResourceDecision, Resource, EntityEntitlements, and GetDecisionMultiResourceResponse with field tables and code examples. Link all Returns sections to the type references. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
♻️ Duplicate comments (2)
code_samples/policy_code/create_subject_mapping.mdx (1)
67-69:⚠️ Potential issue | 🔴 CriticalDeclare
errin the Go snippet before assignment.Line 67 uses
_, err = ...buterris not declared in this snippet. Use short declaration to keep the example self-contained.Proposed fix
-_, err = client.SubjectMapping.CreateSubjectMapping(context.Background(), subjectMapping) +_, err := client.SubjectMapping.CreateSubjectMapping(context.Background(), subjectMapping) if err != nil { log.Fatal(err) }#!/bin/bash # Verify the undeclared-assignment pattern in the snippet. nl -ba code_samples/policy_code/create_subject_mapping.mdx | sed -n '60,72p' rg -nP '_,\s*err\s*=' code_samples/policy_code/create_subject_mapping.mdx rg -nP '\berr\s*:=' code_samples/policy_code/create_subject_mapping.mdxExpected: one
_, err =match and no localerr :=before it in this snippet block.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code_samples/policy_code/create_subject_mapping.mdx` around lines 67 - 69, The snippet uses an assignment to err without declaring it; change the call to CreateSubjectMapping so err is declared locally (e.g., use short declaration for the result from client.SubjectMapping.CreateSubjectMapping) or declare a var err error before the call; update the line invoking client.SubjectMapping.CreateSubjectMapping(context.Background(), subjectMapping) accordingly so the err variable is properly defined in this snippet.code_samples/policy_code/create_attribute.mdx (1)
40-40:⚠️ Potential issue | 🟡 MinorFix the sentence fragment in the
valuesdescription.Line 40 still reads as an incomplete sentence; make the second clause explicit.
Proposed wording tweak
-| `values` | `[]string` | No | Initial values to create with the attribute. Can also be added later via [Create an Attribute Value](`#create-attribute-value`). | +| `values` | `[]string` | No | Initial values to create with the attribute. Values can also be added later via [Create an Attribute Value](`#create-attribute-value`). |🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code_samples/policy_code/create_attribute.mdx` at line 40, The table entry for the `values` field currently ends with a sentence fragment; update the description for `values` (the table cell under `values | []string`) to be a complete sentence such as "Initial values to create with the attribute; these can also be added later via Create an Attribute Value." Ensure the second clause explicitly states that values can be added later and reference the "Create an Attribute Value" anchor text verbatim.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@code_samples/policy_code/create_attribute.mdx`:
- Line 40: The table entry for the `values` field currently ends with a sentence
fragment; update the description for `values` (the table cell under `values |
[]string`) to be a complete sentence such as "Initial values to create with the
attribute; these can also be added later via Create an Attribute Value." Ensure
the second clause explicitly states that values can be added later and reference
the "Create an Attribute Value" anchor text verbatim.
In `@code_samples/policy_code/create_subject_mapping.mdx`:
- Around line 67-69: The snippet uses an assignment to err without declaring it;
change the call to CreateSubjectMapping so err is declared locally (e.g., use
short declaration for the result from
client.SubjectMapping.CreateSubjectMapping) or declare a var err error before
the call; update the line invoking
client.SubjectMapping.CreateSubjectMapping(context.Background(), subjectMapping)
accordingly so the err variable is properly defined in this snippet.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2e20d31c-0fdb-42f1-9f5f-2d3ae0272346
📒 Files selected for processing (7)
code_samples/policy_code/create_attribute.mdxcode_samples/policy_code/create_namespace.mdxcode_samples/policy_code/create_subject_condition_set.mdxcode_samples/policy_code/create_subject_mapping.mdxcode_samples/policy_code/list_subject_mapping.mdxdocs/sdks/platform-client.mdxdocs/sdks/policy.mdx
✅ Files skipped from review due to trivial changes (1)
- code_samples/policy_code/create_namespace.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/sdks/platform-client.mdx
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ations (#274) Full structured documentation for all 14 Obligations operations: - Definitions: List, Get, Get by FQNs, Create, Update, Delete (6) - Values: Get, Get by FQNs, Create, Update, Delete (5) - Triggers: Add, List, Remove (3) Each has Signature, Parameters table, Example, and Returns with links to type references. Added Obligation, Obligation Value, and Obligation Trigger object tables. Updated Setup to use interceptor auth pattern. Fixed action names from "DECRYPT" to "read". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Splitting into smaller PRs for easier review. Changes preserved — see follow-up PRs. |
Summary
Comprehensive SDK documentation cleanup addressing #274 and beyond.
Issue #274 Tasks
Structured API Reference
Added Signature → Parameters → Example → Returns to every operation:
Type References
Architecture Page
Other Improvements
Closes #274
Test plan
🤖 Generated with Claude Code