mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-03 17:24:39 +00:00
Add .Private information to doc-format
This commit is contained in:
@@ -107,6 +107,8 @@ Entity_Flag :: enum u32le {
|
||||
|
||||
Var_Thread_Local = 40,
|
||||
Var_Static = 41,
|
||||
|
||||
Private = 50,
|
||||
}
|
||||
|
||||
Entity_Flags :: distinct bit_set[Entity_Flag; u64le]
|
||||
|
||||
@@ -29,12 +29,12 @@ mutex_try_lock :: proc(m: ^Mutex) -> bool {
|
||||
return _mutex_try_lock(m)
|
||||
}
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if mutex_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if mutex_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
@(deferred_in=mutex_unlock)
|
||||
mutex_guard :: proc(m: ^Mutex) -> bool {
|
||||
mutex_lock(m)
|
||||
@@ -80,25 +80,24 @@ rw_mutex_shared_unlock :: proc(rw: ^RW_Mutex) {
|
||||
rw_mutex_try_shared_lock :: proc(rw: ^RW_Mutex) -> bool {
|
||||
return _rw_mutex_try_shared_lock(rw)
|
||||
}
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if rw_mutex_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if rw_mutex_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
@(deferred_in=rw_mutex_unlock)
|
||||
rw_mutex_guard :: proc(m: ^RW_Mutex) -> bool {
|
||||
rw_mutex_lock(m)
|
||||
return true
|
||||
}
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if rw_mutex_shared_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if rw_mutex_shared_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
@(deferred_in=rw_mutex_shared_unlock)
|
||||
rw_mutex_shared_guard :: proc(m: ^RW_Mutex) -> bool {
|
||||
rw_mutex_shared_lock(m)
|
||||
@@ -127,13 +126,12 @@ recursive_mutex_try_lock :: proc(m: ^Recursive_Mutex) -> bool {
|
||||
return _recursive_mutex_try_lock(m)
|
||||
}
|
||||
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if recursive_mutex_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if recursive_mutex_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
@(deferred_in=recursive_mutex_unlock)
|
||||
recursive_mutex_guard :: proc(m: ^Recursive_Mutex) -> bool {
|
||||
recursive_mutex_lock(m)
|
||||
|
||||
@@ -82,13 +82,12 @@ atomic_mutex_try_lock :: proc(m: ^Atomic_Mutex) -> bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if atomic_mutex_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if atomic_mutex_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
@(deferred_in=atomic_mutex_unlock)
|
||||
atomic_mutex_guard :: proc(m: ^Atomic_Mutex) -> bool {
|
||||
atomic_mutex_lock(m)
|
||||
@@ -193,25 +192,24 @@ atomic_rw_mutex_try_shared_lock :: proc(rw: ^Atomic_RW_Mutex) -> bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if atomic_rw_mutex_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if atomic_rw_mutex_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
@(deferred_in=atomic_rw_mutex_unlock)
|
||||
atomic_rw_mutex_guard :: proc(m: ^Atomic_RW_Mutex) -> bool {
|
||||
atomic_rw_mutex_lock(m)
|
||||
return true
|
||||
}
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if atomic_rw_mutex_shared_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if atomic_rw_mutex_shared_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
@(deferred_in=atomic_rw_mutex_shared_unlock)
|
||||
atomic_rw_mutex_shared_guard :: proc(m: ^Atomic_RW_Mutex) -> bool {
|
||||
atomic_rw_mutex_shared_lock(m)
|
||||
@@ -270,13 +268,12 @@ atomic_recursive_mutex_try_lock :: proc(m: ^Atomic_Recursive_Mutex) -> bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if atomic_recursive_mutex_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if atomic_recursive_mutex_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
@(deferred_in=atomic_recursive_mutex_unlock)
|
||||
atomic_recursive_mutex_guard :: proc(m: ^Atomic_Recursive_Mutex) -> bool {
|
||||
atomic_recursive_mutex_lock(m)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//+private
|
||||
package sync2
|
||||
|
||||
import "core:time"
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package sync2
|
||||
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
guard :: proc{
|
||||
mutex_guard,
|
||||
rw_mutex_guard,
|
||||
@@ -17,13 +16,12 @@ guard :: proc{
|
||||
atomic_recursive_mutex_guard,
|
||||
atomic_rw_mutex_guard,
|
||||
}
|
||||
|
||||
// Example:
|
||||
//
|
||||
// if shared_guard(&m) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
/*
|
||||
Example:
|
||||
if shared_guard(&m) {
|
||||
...
|
||||
}
|
||||
*/
|
||||
shared_guard :: proc{
|
||||
rw_mutex_shared_guard,
|
||||
atomic_rw_mutex_shared_guard,
|
||||
|
||||
@@ -172,6 +172,8 @@ enum OdinDocEntityFlag : u64 {
|
||||
|
||||
OdinDocEntityFlag_Var_Thread_Local = 1ull<<40,
|
||||
OdinDocEntityFlag_Var_Static = 1ull<<41,
|
||||
|
||||
OdinDocEntityFlag_Private = 1ull<<50,
|
||||
};
|
||||
|
||||
struct OdinDocEntity {
|
||||
|
||||
@@ -815,7 +815,7 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) {
|
||||
String link_name = {};
|
||||
|
||||
OdinDocEntityKind kind = OdinDocEntity_Invalid;
|
||||
u32 flags = 0;
|
||||
u64 flags = 0;
|
||||
i32 field_group_index = -1;
|
||||
|
||||
switch (e->kind) {
|
||||
@@ -866,6 +866,9 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) {
|
||||
if (e->flags & EntityFlag_NoAlias) { flags |= OdinDocEntityFlag_Param_NoAlias; }
|
||||
if (e->flags & EntityFlag_AnyInt) { flags |= OdinDocEntityFlag_Param_AnyInt; }
|
||||
}
|
||||
if (e->scope && (e->scope->flags & (ScopeFlag_File|ScopeFlag_Pkg)) && !is_entity_exported(e)) {
|
||||
flags |= OdinDocEntityFlag_Private;
|
||||
}
|
||||
|
||||
OdinDocString init_string = {};
|
||||
if (init_expr) {
|
||||
|
||||
@@ -543,10 +543,13 @@ write_type :: proc(using writer: ^Type_Writer, type: doc.Type, flags: Write_Type
|
||||
e := entities[type_entites[0]]
|
||||
name := str(type.name)
|
||||
tn_pkg := files[e.pos.file].pkg
|
||||
|
||||
if tn_pkg != pkg {
|
||||
fmt.wprintf(w, `%s.`, str(pkgs[tn_pkg].name))
|
||||
}
|
||||
if n := strings.contains_rune(name, '('); n >= 0 {
|
||||
if .Private in e.flags {
|
||||
io.write_string(w, name)
|
||||
} else if n := strings.contains_rune(name, '('); n >= 0 {
|
||||
fmt.wprintf(w, `<a class="code-typename" href="{2:s}/{0:s}/#{1:s}">{1:s}</a>`, pkg_to_path[&pkgs[tn_pkg]], name[:n], BASE_CORE_URL)
|
||||
io.write_string(w, name[n:])
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user