# Documenting class fields

**URL:** <https://racket.discourse.group/t/documenting-class-fields/1258>\
**Category:** Questions & Answers\
**Tags:** scribble\
**Created:** [August 27, 2022, 2:08pm UTC](https://racket.discourse.group/t/documenting-class-fields/1258 "2022-08-27T14:08:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [August 27, 2022, 2:08pm UTC](https://racket.discourse.group/t/documenting-class-fields/1258/1 "2022-08-27T14:08:14Z")

</div>

Hi,

What is the canonical way to document class fields in Scribble?

Consider for example the following code:

```scheme
#lang typed/racket

(define my-class%
  (class object%
    (super-new)
    (init-field [public-integer : Integer])))

(define obj (new my-class% [public-integer 3]))
(set-field! public-integer obj 4)
(get-field public-integer obj)

```

How would I write a Scribble documentation entry for `public-integer`?

The obvious section [4.2.4&nbsp;Documenting Classes and Interfaces](https://docs.racket-lang.org/scribble/doc-classes.html) does not seem to mention field documentation, and after a quick search in the class-rich [GitHub - racket/gui](https://github.com/racket/gui) I don't seem to find any examples.

Is it because publicly exposing fields is strongly discouraged? I don't see this message in the docs, but maybe I am missing something.

---

<div class="post-metadata">

**Author:** ![mflatt](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/mflatt/32/6_2.png) [@mflatt](https://racket.discourse.group/u/mflatt)\
**Post date:** [August 30, 2022, 1:50pm UTC](https://racket.discourse.group/t/documenting-class-fields/1258/2 "2022-08-30T13:50:31Z")

</div>

Does `@defthing[field-name #:kind "field"]{...}` work? I think I may have used that before, and it rendered ok for me a quick experiment.

---

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [August 31, 2022, 8:58pm UTC](https://racket.discourse.group/t/documenting-class-fields/1258/3 "2022-08-31T20:58:44Z")

</div>

Thank you for your suggestion @mflatt ! `defthing` almost works for me: the only missing detail is scoping. In my case, I want to document a field of a class which has the same name as a structure in the same module. More concretely, I am defining a class called `dynamics%` which has a field called `network`, and in the same module I define a structure called `network`, instances of which are supposed to be put into the field `network` of `dynamics%`.

I am currently looking into the implementation of `defmethod`, since it seems to solve the scoping issue, but I'd appreciate some additional pointers 🙂
