fixed generation errors

This commit is contained in:
Roman Trapeznikov 2022-02-10 19:08:10 +03:00
parent c09770b9da
commit 723a7744cf
No known key found for this signature in database
GPG Key ID: 89BED52F1E290F8D
9 changed files with 113 additions and 89 deletions

View File

@ -4,6 +4,7 @@
<w>gamename</w>
<w>maxlen</w>
<w>pagename</w>
<w>unhashable</w>
</words>
</dictionary>
</component>

View File

@ -29,102 +29,102 @@ class BombFactory:
Attributes:
bomb_model
bomb_model: ba.Model
The ba.Model of a standard or ice bomb.
sticky_bomb_model
sticky_bomb_model: ba.Model
The ba.Model of a sticky-bomb.
impact_bomb_model
impact_bomb_model: ba.Model
The ba.Model of an impact-bomb.
land_mine_model
land_mine_model: ba.Model
The ba.Model of a land-mine.
tnt_model
tnt_model: ba.Model
The ba.Model of a tnt box.
regular_tex
regular_tex: ba.Texture
The ba.Texture for regular bombs.
ice_tex
ice_tex: ba.Texture
The ba.Texture for ice bombs.
sticky_tex
sticky_tex: ba.Texture
The ba.Texture for sticky bombs.
impact_tex
impact_tex: ba.Texture
The ba.Texture for impact bombs.
impact_lit_tex
impact_lit_tex: ba.Texture
The ba.Texture for impact bombs with lights lit.
land_mine_tex
land_mine_tex: ba.Texture
The ba.Texture for land-mines.
land_mine_lit_tex
land_mine_lit_tex: ba.Texture
The ba.Texture for land-mines with the light lit.
tnt_tex
tnt_tex: ba.Texture
The ba.Texture for tnt boxes.
hiss_sound
hiss_sound: ba.Sound
The ba.Sound for the hiss sound an ice bomb makes.
debris_fall_sound
debris_fall_sound: ba.Sound
The ba.Sound for random falling debris after an explosion.
wood_debris_fall_sound
wood_debris_fall_sound: ba.Sound
A ba.Sound for random wood debris falling after an explosion.
explode_sounds
explode_sounds: Sequence[ba.Sound]
A tuple of ba.Sounds for explosions.
freeze_sound
freeze_sound: ba.Sound
A ba.Sound of an ice bomb freezing something.
fuse_sound
fuse_sound: ba.Sound
A ba.Sound of a burning fuse.
activate_sound
activate_sound: ba.Sound
A ba.Sound for an activating impact bomb.
warn_sound
warn_sound: ba.Sound
A ba.Sound for an impact bomb about to explode due to time-out.
bomb_material
bomb_material: ba.Material
A ba.Material applied to all bombs.
normal_sound_material
normal_sound_material: ba.Material
A ba.Material that generates standard bomb noises on impacts, etc.
sticky_material
sticky_material: ba.Material
A ba.Material that makes 'splat' sounds and makes collisions softer.
land_mine_no_explode_material
land_mine_no_explode_material: ba.Material
A ba.Material that keeps land-mines from blowing up.
Applied to land-mines when they are created to allow land-mines to
touch without exploding.
land_mine_blast_material
land_mine_blast_material: ba.Material
A ba.Material applied to activated land-mines that causes them to
explode on impact.
impact_blast_material
impact_blast_material: ba.Material
A ba.Material applied to activated impact-bombs that causes them to
explode on impact.
blast_material
blast_material: ba.Material
A ba.Material applied to bomb blast geometry which triggers impact
events with what it touches.
dink_sounds
dink_sounds: Sequence[ba.Sound]
A tuple of ba.Sounds for when bombs hit the ground.
sticky_impact_sound
sticky_impact_sound: ba.Sound
The ba.Sound for a squish made by a sticky bomb hitting something.
roll_sound
roll_sound: ba.Sound
ba.Sound for a rolling bomb.
"""

View File

@ -24,20 +24,20 @@ class FlagFactory:
Attributes:
flagmaterial
flagmaterial: ba.Material
The ba.Material applied to all ba.Flags.
impact_sound
impact_sound: ba.Sound
The ba.Sound used when a ba.Flag hits the ground.
skid_sound
skid_sound: ba.Sound
The ba.Sound used when a ba.Flag skids along the ground.
no_hit_material
no_hit_material: ba.Material
A ba.Material that prevents contact with most objects;
applied to 'non-touchable' flags.
flag_texture
flag_texture: ba.Texture
The ba.Texture for flags.
"""

View File

@ -23,7 +23,7 @@ class PlayerSpazHurtMessage:
Attributes:
spaz
spaz: ba.PlayerSpaz
The ba.PlayerSpaz that was hurt
"""

View File

@ -30,52 +30,52 @@ class PowerupBoxFactory:
Attributes:
model
model: ba.Model
The ba.Model of the powerup box.
model_simple
model_simple: ba.Model
A simpler ba.Model of the powerup box, for use in shadows, etc.
tex_bomb
tex_bomb: ba.Texture
Triple-bomb powerup ba.Texture.
tex_punch
tex_punch: ba.Texture
Punch powerup ba.Texture.
tex_ice_bombs
tex_ice_bombs: ba.Texture
Ice bomb powerup ba.Texture.
tex_sticky_bombs
tex_sticky_bombs: ba.Texture
Sticky bomb powerup ba.Texture.
tex_shield
tex_shield: ba.Texture
Shield powerup ba.Texture.
tex_impact_bombs
tex_impact_bombs: ba.Texture
Impact-bomb powerup ba.Texture.
tex_health
tex_health: ba.Texture
Health powerup ba.Texture.
tex_land_mines
tex_land_mines: ba.Texture
Land-mine powerup ba.Texture.
tex_curse
tex_curse: ba.Texture
Curse powerup ba.Texture.
health_powerup_sound
health_powerup_sound: ba.Sound
ba.Sound played when a health powerup is accepted.
powerup_sound
powerup_sound: ba.Sound
ba.Sound played when a powerup is accepted.
powerdown_sound
powerdown_sound: ba.Sound
ba.Sound that can be used when powerups wear off.
powerup_material
powerup_material: ba.Material
ba.Material applied to powerup boxes.
powerup_accept_material
powerup_accept_material: ba.Material
Powerups will send a ba.PowerupMessage to anything they touch
that has this ba.Material applied.
"""
@ -194,12 +194,12 @@ class PowerupBox(ba.Actor):
Attributes:
poweruptype
poweruptype: str
The string powerup type. This can be 'triple_bombs', 'punch',
'ice_bombs', 'impact_bombs', 'land_mines', 'sticky_bombs', 'shield',
'health', or 'curse'.
node
node: ba.Node
The 'prop' ba.Node representing this box.
"""

View File

@ -52,7 +52,7 @@ class Spaz(ba.Actor):
Attributes:
node
node: ba.Node
The 'spaz' ba.Node.
"""

View File

@ -31,10 +31,10 @@ class SpazBotPunchedMessage:
Attributes:
spazbot
spazbot: ba.SpazBot
The ba.SpazBot that got punched.
damage
damage: int
How much damage was done to the ba.SpazBot.
"""
@ -51,13 +51,13 @@ class SpazBotDiedMessage:
Attributes:
spazbot
spazbot: ba.SpazBot
The ba.SpazBot that was killed.
killerplayer
killerplayer: ba.Player
The ba.Player that killed it (or None).
how
how: ba.DeathType
The particular type of death.
"""

View File

@ -25,55 +25,55 @@ class SpazFactory:
Attributes:
impact_sounds_medium
impact_sounds_medium: Sequence[ba.Sound]
A tuple of ba.Sounds for when a ba.Spaz hits something kinda hard.
impact_sounds_hard
impact_sounds_hard: Sequence[ba.Sound]
A tuple of ba.Sounds for when a ba.Spaz hits something really hard.
impact_sounds_harder
impact_sounds_harder: Sequence[ba.Sound]
A tuple of ba.Sounds for when a ba.Spaz hits something really
really hard.
single_player_death_sound
single_player_death_sound: ba.Sound
The sound that plays for an 'important' spaz death such as in
co-op games.
punch_sound
punch_sound: ba.Sound
A standard punch ba.Sound.
punch_sound_strong
punch_sound_strong: Sequence[ba.Sound]
A tuple of stronger sounding punch ba.Sounds.
punch_sound_stronger
punch_sound_stronger: ba.Sound
A really really strong sounding punch ba.Sound.
swish_sound
swish_sound: ba.Sound
A punch swish ba.Sound.
block_sound
block_sound: ba.Sound
A ba.Sound for when an attack is blocked by invincibility.
shatter_sound
shatter_sound: ba.Sound
A ba.Sound for when a frozen ba.Spaz shatters.
splatter_sound
splatter_sound: ba.Sound
A ba.Sound for when a ba.Spaz blows up via curse.
spaz_material
spaz_material: ba.Material
A ba.Material applied to all of parts of a ba.Spaz.
roller_material
roller_material: ba.Material
A ba.Material applied to the invisible roller ball body that
a ba.Spaz uses for locomotion.
punch_material
punch_material: ba.Material
A ba.Material applied to the 'fist' of a ba.Spaz.
pickup_material
pickup_material: ba.Material
A ba.Material applied to the 'grabber' body of a ba.Spaz.
curse_material
curse_material: ba.Material
A ba.Material applied to a cursed ba.Spaz that triggers an explosion.
"""

View File

@ -397,7 +397,9 @@ class BaseGenerator:
AttributeInfo]]] = {}
self._out = ''
self._classes: list[ClassInfo] = []
self._class_names: set[str] = set()
self._functions: list[FunctionInfo] = []
self._function_names: set[str] = set()
self._merged_categories: list[tuple[str, str,
list[Union[ClassInfo,
FunctionInfo]]]] = []
@ -707,8 +709,7 @@ class BaseGenerator:
for cls in self._classes:
key = cls.name
if key in self._index:
# print('duplicate index entry:', key)
continue
print(f'WARNING: duplicate index entry: {key}')
self._index[key] = (_get_class_href(cls.name), cls)
self._index_keys.append(key)
@ -716,8 +717,7 @@ class BaseGenerator:
for mth in cls.methods:
key = cls.name + '.' + mth.name
if key in self._index:
# print('duplicate index entry:', key)
continue
print(f'WARNING: duplicate index entry: {key}')
self._index[key] = (_get_method_href(cls.name, mth.name), mth)
self._index_keys.append(key)
@ -725,8 +725,7 @@ class BaseGenerator:
for attr in cls.attributes:
key = cls.name + '.' + attr.name
if key in self._index:
# print('duplicate index entry:', key)
continue
print(f'WARNING: duplicate index entry: {key}')
self._index[key] = (_get_attribute_href(cls.name,
attr.name), attr)
self._index_keys.append(key)
@ -735,8 +734,7 @@ class BaseGenerator:
for fnc in self._functions:
key = fnc.name
if key in self._index:
# print('duplicate index entry:', key)
continue
print(f'WARNING: duplicate index entry: {key}')
self._index[key] = (_get_function_href(fnc.name), fnc)
self._index_keys.append(key)
@ -1114,8 +1112,9 @@ class BaseGenerator:
category=_get_category(
docs, CategoryType.FUNCTION),
docs=docs)
if '(internal)' not in docs:
if '(internal)' not in docs and f_info.name not in self._function_names:
self._functions.append(f_info)
self._function_names.add(f_info.name)
def _process_classes(self, module: ModuleType) -> None:
classes_by_name = _get_module_classes(module)
@ -1135,7 +1134,9 @@ class BaseGenerator:
category=_get_category(docs,
CategoryType.CLASS),
attributes=attrs)
self._classes.append(c_info)
if c_info.name not in self._class_names:
self._classes.append(c_info)
self._class_names.add(c_info.name)
def _write_category_list(self) -> None:
for cname, ctype, cmembers in self._merged_categories:
@ -1207,13 +1208,35 @@ class BaseGenerator:
import ba
print(f"Generating docs file: '{Clr.BLU}{outfilename}{Clr.RST}'...")
# Collect everything we want to generate docs for.
self._collect_submodules(self.get_top_module())
submodules = list(sorted(self._submodules, key=lambda x: x.__name__))
print([sm.__name__ for sm in submodules])
print(f'{self.top_module_name} submodules:\n -->',
'\n --> '.join([sm.__name__ for sm in submodules]))
for module in submodules:
self._gather_funcs(module)
self._process_classes(module)
# Remove duplicates. This probably should be handled at
# self._gather_funcs/self._process_classes level (i.e. just not to add
# already existing things), but the main problem is unhashable
# ClassInfo dataclass which leads to O(N^2) asymptotic (though I didn't
# check how exactly slow it would be).
# funcs = self._functions
# funcs.sort(key=lambda x: x.name)
# f_last: Optional[FunctionInfo] = None
# self._functions = []
# for func in funcs:
# if func.name == f_last.name:
# continue
# f_last = func
# self._functions.append(func)
self._functions.sort(key=lambda x: x.name)
self._classes.sort(key=lambda x: x.name)
# Start with our list of classes and functions.
app = ba.app
self._out += ('<h4><em>last updated on ' + str(datetime.date.today()) +
@ -1304,7 +1327,7 @@ class BaseGenerator:
with open(outfilename, 'w', encoding='utf-8') as outfile:
outfile.write(self._out)
print(f"Generated docs file: '{Clr.BLU}{outfilename}.{Clr.RST}'")
print(f"Generated docs file: '{Clr.BLU}{outfilename}{Clr.RST}'.")
class BaModuleGenerator(BaseGenerator):